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 does socket consist of?
Are sockets full duplex?
How to Specify an X.25 Address?
How TCP/IP Handles Sequencing?
What is the use of SOCK_DGRAM Socket Type?
What is the use of PF_INET and SOCK_DGRAM?
What are Reserved IP Numbers?
Can you send and receive on the same socket at the same time?
How to read socket file in linux?
How to perform I/O on Sockets?
What is socket linux?
How to Bind Addresses to a Socket?
How to Form Abstract Local Addresses?
How socket is created?
How does socket communication work?