Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the Use of the inet_makeaddr() Function?

1374


What are Private IP Numbers?

1272


HOW TCP/IP Handles Duplicated Packets?

1657


Are sockets full duplex?

850


How to Deal with Duplicated Sockets?

1557


What is Internet Address Classes?

1417


How to Test the Datagram Client and Server?

1494


What are Reserved IP Numbers?

1408


How to Form Local Addresses?

1488


How to Define a Socket?

1418


Are sockets bidirectional?

854


What does socket consist of?

874


What is the use of PF_INET or AF_INET?

1621


How to open socket file in linux?

1085


What are the different types of sockets?

951