What is the difference between connected and unconnected sockets?
Answer / chaitanya
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.
| Is This Answer Correct ? | 1 Yes | 0 No |
of the socket? Does doing a connect() call affect the receive behaviour?
Why do I get connection refused when the server is not running?
Why does the sockets buffer fill up sooner than expected?
How does a socket work?
How can I force a socket to send the data in its buffer?
How can I listen on more than one port at a time?
Explain the TIME_WAIT state.
Can a socket have multiple ports?
How can I be sure that UDP messages are received in order?
Why do I keep getting EINTR from the socket calls?
When should I use shutdown()?
How would I put my socket in non-blocking mode?