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

What does af mean in sockets?

520


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?

1040


What is a socket file?

510


What is af_inet in socket?

475


How many sockets can a cpu have?

499






What is socket address?

570


What is a deep well socket?

520


What is socket programming in java?

492


How does a socket work?

491


system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?

1163


How can I tell when a socket is closed on the other end?

973


Are sockets files?

500


What is a socket address?

520


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

978


What is the difference between read() and recv()?

1593