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 pieces of information make up a socket?
How does a socket work?
What is socket address with example?
Why do I keep getting EINTR from the socket calls?
What is af_inet in socket?
How can I be sure that UDP messages are received in order?
Why do I get connection refused when the server is not running?
over the socket? Is there a way to have a dynamic buffer? What does one do when one does not know how much information is coming?
What is the difference between a socket and a port?
What is the difference between close() and shutdown()?
When should I use UDP instead of TCP?
How should I choose a port number for my server?