How do Sockets Work?
Answer / chaitanya
The implementation is left up to the vendor of your particular unix, but from the point of view of the programmer, connection-oriented sockets work a lot like files, or pipes. The most noticeable difference, once you have your file descriptor is that read() or write() calls may actually read or write fewer bytes than requested. If this happens, then you will have to make a second call for the rest of the data. There are examples of this in the source code that accompanies the faq.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is a socket set used for?
Why do I get connection refused when the server is not running?
system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?
How to find other end of unix socket connection?
How can my client work through a firewall/proxy server?
What does af mean in sockets?
When will my application receive SIGPIPE?
How can I listen on more than one port at a time?
Is there any advantage to handling the signal, rather than just ignoring it and checking for the EPIPE error? Are there any useful parameters passed to the signal catching function?
How many sockets can a cpu have?
Is tcp or unix socket faster?
How can I put a timeout on connect()?