cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Beginners : Socket initialisation code lines
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programm...
Articles
Lounge
Jobs

-

question  Socket initialisation code lines

Daniel A (7)
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
Umz (153)
This document explains socket programming quite well
www.rites.uic.edu/~solworth/sockets.pdf
|
bnbertha (404)
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
|
Daniel A (7)
Thanks!!!! That's really helpfull :)
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2009 - All rights reserved - v2.2
Spotted an error? contact us