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
What is the Use of the inet_makeaddr() Function?
What are Private IP Numbers?
HOW TCP/IP Handles Duplicated Packets?
Are sockets full duplex?
How to Deal with Duplicated Sockets?
What is Internet Address Classes?
How to Test the Datagram Client and Server?
What are Reserved IP Numbers?
How to Form Local Addresses?
How to Define a Socket?
Are sockets bidirectional?
What does socket consist of?
What is the use of PF_INET or AF_INET?
How to open socket file in linux?
What are the different types of sockets?