| kaidto (12) | |||
|
Hello! I'm trying to start programming sockets, but have no idea where to start from!! There is a lot of documentation, BUT! I'm kind of confused with it. this is my server code
What about read and write functions?Why is the socket being closed trought close(fdl);?AF_INET or AF_INET6?Should I create this struct? struct sockaddr_in dir = { AF_INET, htons(15557), INADDR_ANY};this web page, shows totally different info from what I posted? http://www.linuxhowtos.org/C_C++/socket.htm Any Ideas from where to start? Thanks in advance! Regards! | |||
|
Last edited on
|
|||
| kbw (5517) | |||||||
When a client connects, that connection is returned by accept() and you store it as fdc (file descriptor for client) http://pubs.opengroup.org/onlinepubs/007908799/xns/accept.html The server's listening socket is being closed because it does not want to accept any further connections.
An end point is a port on an address. But as you've specified INADDR_ANY, you're saying you want to bind to port 15557 on any network interface IP4 (AF_INET) that your computer has. htos() means host to network short and deals with endian issues on your computer.http://pubs.opengroup.org/onlinepubs/007908799/xns/htonl.html http://en.wikipedia.org/wiki/Endianness
| |||||||
|
|
|||||||
| kaidto (12) | |
|
Hmm, Thanks a lot!!! that web page looks kind of interesting I will read it from start to end. ok, and, if we want to prepare our server to receive multiple connections, what should we use? Threads? we need a main while(true) loop or something like that? | |
|
|
|
| kaidto (12) | |
|
Incredible documentation. Thanks. REALLY, THANKS! | |
|
|
|