What is the difference between connected and unconnected sockets?



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

Post New Answer

More Unix Socket Programming Interview Questions

Can multiple clients connect to same socket?

0 Answers  


How can I set the timeout for the connect() system call?

0 Answers  


How can I find the full hostname (FQDN) of the system I am running on?

1 Answers  


What's better 6pt or 12pt sockets?

0 Answers  


How can I read ICMP errors from connected UDP sockets?

1 Answers  






Is a socket a file?

0 Answers  


How can I be sure that UDP messages are received in order?

1 Answers  


How many sockets can a cpu have?

0 Answers  


After the chroot(), calls to socket() are failing. Why?

1 Answers  


How does unix socket work?

0 Answers  


How come select says there is data, but read returns zero?

1 Answers  


How would I put my socket in non-blocking mode?

1 Answers  


Categories