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 is the function of socket?

678


What is socket address with example?

652


Are unix sockets faster than tcp?

647


What is a socket file?

667


What is a socket set used for?

702


What's better 6pt or 12pt sockets?

622


system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?

1308


Is socket a hardware or software?

682


What is a socket address?

696


What is af_inet in socket?

630


Can a single socket port be used for multiple applications?

637


What is sae socket?

607


Can a socket have multiple ports?

652


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

623


Where is the socket located?

650