Unix Socket Programming Question:

Download Job Interview Questions and Answers PDF

What is the difference between connected and unconnected sockets?

Unix Socket Programming Interview Question
Unix Socket Programming Interview Question

Answer:

If a UDP socket is unconnected, which is the normal state after a bind() call, then send() or write() are not allowed, since no destination address is available; only sendto() can be used to send data.

Calling connect() on the socket simply records the specified address and port number as being the desired communications partner. That means that send() or write() are now allowed; they use the destination address and port given on the connect call as the destination of the packet.

Download Unix Socket Programming Interview Questions And Answers PDF

Previous QuestionNext Question
How can I write a multi-homed server?How can I read ICMP errors from connected UDP sockets?