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 socket linux?
What is the use of setprotoent(3) Function?
Why socket programming is used?
How to Define a Socket?
How to Specify an X.25 Address?
What are Reserved IP Numbers?
Why bind system call is required in socket programming?
How to Generate Addresses?
What is the use of inet_network()?
How to Initialize a Wild Internet Address?
What are Anonymous Calls?
how to get client port number in server socket programming??
How to Bind a Specific Interface Address?
How to Test with Other IP Numbers?
How to Close Sockets?