How Do Sockets Work in C?

Posted by kaybenleroll on Stack Overflow See other posts from Stack Overflow or by kaybenleroll
Published on 2008-09-08T00:00:32Z Indexed on 2011/02/24 7:24 UTC
Read the original article Hit count: 186

Filed under:
|
|

I am a bit confused about socket programming in C.

You create a socket, bind it to an interface and an IP address and get it to listen. I found a couple of web resources on that, and understood it fine. In particular, I found an article Network programming under Unix systems to be very informative.

What confuses me is the timing of data arriving on the socket.

How can you tell when packets arrive, and how big the packet is, do you have to do all the heavy lifting yourself? My basic assumption here is that packets can be of variable length, so once binary data starts appearing down the socket, how do you begin to construct packets from that?

© Stack Overflow or respective owner

Related posts about c

    Related posts about sockets