How do Sockets Work?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I set the timeout for the connect() system call?

1245


What are the pros/cons of select(), non-blocking I/O and SIGIO?

1102


What is active unix domain sockets?

693


What is a sae socket?

694


What is sae socket?

594






Can multiple clients connect to same socket?

643


What is a socket api?

653


Are unix sockets faster than tcp?

636


Why does it take so long to detect that the peer died?

1294


What is a deep well socket?

683


Why does the sockets buffer fill up sooner than expected?

1116


What is socket address with example?

637


What pieces of information make up a socket?

719


Whats the difference between select() and poll()?

1366


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?

1181