Socket initialisation code lines

Hi volks,

Could anyone tell me what does every line mean and why it has to be used?
The only thing I know that it is about socket programming :)


addr_.sin_family = AF_INET;
101 addr_.sin_port = 0;
102 addr_.sin_addr.s_addr = INADDR_ANY;

Thanks in advance..

Dan
Last edited on
This document explains socket programming quite well
www.rites.uic.edu/~solworth/sockets.pdf
These three lines set up a structure for configuring a network socket, in this case a TCP/IP or UDP socket.
The first one sets the protocol, in this case IPv4
The second one sets the network port to use (zero) and the third sets the IP address. In this case you don't care, letting the OS do it for you. These three setting are typically used in the bind() call on a local socket.

Hope this helps
Thanks!!!! That's really helpfull :)
Topic archived. No new replies allowed.