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...

What is with the second parameter in bind()?

Answer Posted / chaitanya

The man page shows it as "struct sockaddr *my_addr". The sockaddr struct though is just a place holder for the structure it really wants. You have to pass different structures depending on what kind of socket you have. For an AF_INET socket, you need the sockaddr_in structure. It has three fields of interest:

sin_family

Set this to AF_INET.

sin_port

The network byte-ordered 16 bit port number

sin_addr

The host's ip number.

This is a struct in_addr,

which contains only one field,

s_addr which is a u_long.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?

1667


What is af_inet in socket?

875


What is socket address with example?

906


How do I convert a string into an internet address?

1427


What is the difference between a socket and a port?

929


Why sockets are used?

934


How does a socket work?

918


Can multiple sockets use the same port?

921


How can I tell when a socket is closed on the other end?

1389


Can a single socket port be used for multiple applications?

925


What are the types of sockets?

970


Are sockets files?

929


What is sae socket?

890


Why do we need sockets?

890


Is tcp or unix socket faster?

899