About Me Recommended Reading

Welcome of the web site for the UNIX Socket FAQ! I will be getting back to updating this site soon, to restore the old links, etc. I'll also automate the mirroring so new questions go out to the mirror sites.

Please help a friend of mine who is promoting his single by downloading and listening to 'Notawasaga'. You'll be helping him to find more listeners, and maybe it'll help soothe your nerves when your clients and servers just aren't communicating like they should.

You are using a static mirror of the faq, so not all features will be available to you. The home page that has all the features can be found at http://www.lcg.org/sock-faq/.

Categorized Questions:

  1. General Information and Concepts
    1. What's new?
    2. About this FAQ
    3. Who is this FAQ for?
    4. What are Sockets?
    5. How do Sockets Work?
    6. Where can I get source code for the book [book title]?
    7. Where can I get more information?
    8. Where can I get the sample source code?
  2. Questions regarding both Clients and Servers (TCP/SOCK_STREAM)
    1. How can I tell when a socket is closed on the other end?
    2. What's with the second parameter in bind()?
    3. How do I get the port number for a given service?
    4. If bind() fails, what should I do with the socket descriptor?
    5. How do I properly close a socket?
    6. When should I use shutdown()?
    7. Please explain the TIME_WAIT state.
    8. Why does it take so long to detect that the peer died?
    9. What are the pros/cons of select(), non-blocking I/O and SIGIO?
    10. Why do I get EPROTO from read()?
    11. How can I force a socket to send the data in its buffer?
    12. Where can I get a library for programming sockets?
    13. How come select says there is data, but read returns zero?
    14. Whats the difference between select() and poll()?
    15. How do I send [this] over a socket
    16. How do I use TCP_NODELAY?
    17. What exactly does the Nagle algorithm do?
    18. What is the difference between read() and recv()?
    19. I see that send()/write() can generate SIGPIPE. Is there any advantage to handling the signal, rather than just ignoring it and checking for the EPIPE error?
    20. After the chroot(), calls to socket() are failing. Why?
    21. Why do I keep getting EINTR from the socket calls?
    22. When will my application receive SIGPIPE?
    23. What are socket exceptions? What is out-of-band data?
    24. How can I find the full hostname (FQDN) of the system I'm running on?
  3. Writing Client Applications (TCP/SOCK_STREAM)
    1. How do I convert a string into an internet address?
    2. How can my client work through a firewall/proxy server?
    3. Why does connect() succeed even before my server did an accept()?
    4. Why do I sometimes lose a server's address when using more than one server?
    5. How can I set the timeout for the connect() system call?
    6. Should I bind() a port number in my client program, or let the system choose one for me on the connect() call?
    7. Why do I get "connection refused" when the server isn't running?
    8. What does one do when one does not know how much information is comming over the socket? Is there a way to have a dynamic buffer?
  4. Writing Server Applications (TCP/SOCK_STREAM)
    1. How come I get "address already in use" from bind()?
    2. Why don't my sockets close?
    3. How can I make my server a daemon?
    4. How can I listen on more than one port at a time?
    5. What exactly does SO_REUSEADDR do?
    6. What exactly does SO_LINGER do?
    7. What exactly does SO_KEEPALIVE do?
    8. 4.8 How can I bind() to a port number < 1024?
    9. How do I get my server to find out the client's address / hostname?
    10. How should I choose a port number for my server?
    11. What is the difference between SO_REUSEADDR and SO_REUSEPORT?
    12. How can I write a multi-homed server?
    13. How can I read only one character at a time?
    14. I'm trying to exec() a program from my server, and attach my socket's IO to it, but I'm not getting all the data across. Why?
  5. Writing UDP/SOCK_DGRAM applications
    1. When should I use UDP instead of TCP?
    2. What is the difference between "connected" and "unconnected" sockets?
    3. Does doing a connect() call affect the receive behaviour of the socket?
    4. How can I read ICMP errors from "connected" UDP sockets?
    5. How can I be sure that a UDP message is received?
    6. How can I be sure that UDP messages are received in order?
    7. How often should I re-transmit un-acknowleged messages?
    8. How come only the first part of my datagram is getting through?
    9. Why does the socket's buffer fill up sooner than expected?
  6. Advanced Socket Programming
    1. How would I put my socket in non-blocking mode?
    2. How can I put a timeout on connect()?

Add Your Own Question to the FAQ

| About Me || Recommended Reading |

Contents are copyright by the author of the content. Permission is granted to do anything you like with this contents so long as you don't claim the work, or copyright for yourself. Some graphics are copyright© by www.arttoday.com and used with permission. Any questions regarding this site should be directed to vic@acm.org.