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

How to Close Sockets?

1460


What is Internet Address Classes?

1381


How to Deal with Duplicated Sockets?

1519


How to Initialize a Wild Internet Address?

1660


How to Examin the /etc/services File?

1644


Why bind system call is required in socket programming?

822


What is the setservent(3) Function?

1520


What is AF_UNSPEC Address?

2251


What is socket and how it works?

888


What is the use of inet_network()?

1453


What are Nameless Sockets?

1550


How to Form Local Addresses?

1418


HOW TCP/IP Handles Duplicated Packets?

1620


How to Understand Netmask Values?

1320


What are Private IP Numbers?

1217