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()?



What is with the second parameter in bind()?..

Answer / 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

More Unix Socket Programming Interview Questions

What is socket address with example?

0 Answers  


Is there any advantage to handling the signal, rather than just ignoring it and checking for the EPIPE error? Are there any useful parameters passed to the signal catching function?

0 Answers  


Why does connect() succeed even before my server did an accept()?

1 Answers  


Can multiple sockets use the same port?

0 Answers  


How are unix domain sockets implemented?

0 Answers  


What is a socket set used for?

0 Answers  


How do unix sockets work?

0 Answers  


How do Sockets Work?

1 Answers  


Where can a get a library for programming sockets?

1 Answers  


How many sockets can a port have?

0 Answers  


What exactly does SO_REUSEADDR do?

1 Answers  


How come I get address already in use from bind()?

1 Answers  


Categories