how to get client port number in server socket programming??
Answer Posted / rps
@Maddy :-)
After the Accept Call in server Program..
ClientFD = accept(SockFD,(struct sockaddr *)&ClientAddr,(int*)&SinSize);
You will get Client IP and Port Number using this --
printf(" Server got a connection from Client (%s : %d)\n",
inet_ntoa(ClientAddr.sin_addr),ntohs(ClientAddr.sin_port));
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
How to Close Sockets?
What is Internet Address Classes?
How to Deal with Duplicated Sockets?
How to Initialize a Wild Internet Address?
How to Examin the /etc/services File?
Why bind system call is required in socket programming?
What is the setservent(3) Function?
What is AF_UNSPEC Address?
What is socket and how it works?
What is the use of inet_network()?
What are Nameless Sockets?
How to Form Local Addresses?
HOW TCP/IP Handles Duplicated Packets?
How to Understand Netmask Values?
What are Private IP Numbers?