How to get client port number in server socket programming?
Submitted by: AdministratorAfter accepting connection on socket of server side. we can
get the client ip address and port by to functions. These
functions are belonging in "/usr/include/arpa/inet.h" header
file.
Here is some scratch from the code.
socket2 = accept(socket1, (struct sockaddr *)&client, &addrlen);
printf("%sn",inet_ntoa(client.sin_addr));
printf("%dn",(int) ntohs(client.sin_port));
Submitted by: Administrator
get the client ip address and port by to functions. These
functions are belonging in "/usr/include/arpa/inet.h" header
file.
Here is some scratch from the code.
socket2 = accept(socket1, (struct sockaddr *)&client, &addrlen);
printf("%sn",inet_ntoa(client.sin_addr));
printf("%dn",(int) ntohs(client.sin_port));
Submitted by: Administrator
Read Online Linux Socket Programming Job Interview Questions And Answers
Top Linux Socket Programming Questions
☺ | What is the difference between a process task and threads and what are the things that are acquired by the child process from the parent process? |
☺ | What is the difference between fork() & exec()? |
☺ | What is the difference between socket & port? |
☺ | Why bind system call is required in socket programming? |
☺ | How to get client port number in server socket programming? |
Top Linux OS Categories
☺ | Device Drivers Interview Questions. |
☺ | Linux OS Management Interview Questions. |
☺ | Linux Makefile Interview Questions. |
☺ | Linux Environment Interview Questions. |
☺ | Linux OS Shell Interview Questions. |