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 |
Why do we need socket programming?
How can I bind() to a port number < 1024?
How are unix domain sockets implemented?
What is a socket address?
Why do I get EPROTO from read()?
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?
How do I properly close a socket?
What's the difference between a socket and a port?
How many socket connections can a server handle?
How can I write a multi-homed server?
Are unix sockets faster than tcp?
Is a socket a file?