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 |
Can multiple clients connect to same socket?
How can I set the timeout for the connect() system call?
How can I find the full hostname (FQDN) of the system I am running on?
What's better 6pt or 12pt sockets?
How can I read ICMP errors from connected UDP sockets?
Is a socket a file?
How can I be sure that UDP messages are received in order?
How many sockets can a cpu have?
After the chroot(), calls to socket() are failing. Why?
How does unix socket work?
How come select says there is data, but read returns zero?
How would I put my socket in non-blocking mode?