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
system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?
What is af_inet in socket?
What is socket address with example?
How do I convert a string into an internet address?
What is the difference between a socket and a port?
Why sockets are used?
How does a socket work?
Can multiple sockets use the same port?
How can I tell when a socket is closed on the other end?
Can a single socket port be used for multiple applications?
What are the types of sockets?
Are sockets files?
What is sae socket?
Why do we need sockets?
Is tcp or unix socket faster?