What is the difference between connected and unconnected sockets?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What's the difference between a socket and a port?

458


What is difference between socket and websocket?

485


What is a socket address?

520


How does unix socket work?

506


Can multiple sockets use the same port?

492






How is a socket created?

507


What is socket programming in java?

491


Is socket a hardware or software?

503


What pieces of information make up a socket?

545


What is the purpose of socket?

503


Can a socket have multiple ports?

504


How many sockets can a cpu have?

497


What is a deep well socket?

518


Why does it take so long to detect that the peer died?

1148


Why do we need sockets?

483