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 |
How come only the first part of my datagram is getting through?
How can I be sure that UDP messages are received in order?
How often should I re-transmit un-acknowleged messages?
What exactly does SO_LINGER do?
What is LILO?
How can I set the timeout for the connect() system call?
What exactly does SO_REUSEADDR do?
How to find other end of unix socket connection?
How can I force a socket to send the data in its buffer?
How do I get the port number for a given service?
How many sockets can a port have?
What is active unix domain sockets?