0
votes

As I have understood correctly, we use send() for TCP sockets and sendto() for UDP.

Now, if we have a connected a UDP socket we can use send() to send data without specifying address information.

My question is, does using send() for connected a UDP socket, affect the underlying transport protocol?

More specifically, are the communication semantics (reliable data transfer, conection oriented, etc) affected by the function that we use or the type of the socket?

1

1 Answers

1
votes

As I have understood correctly, we use send() for TCP sockets and sendto() for UDP.

Not really. One uses send for connected sockets and sendto on unconnected sockets - since with send the destination will be retrieved from the socket while with sendto it will be given explicitly.

Since established TCP sockets are always connected this implicitly means that one need to use send on these and not sendto. UDP sockets can be connected or unconnected - in the first case send should be used and in the second sendto. This does not affect the protocol used, i.e. it still is unreliable UDP. It only affects where the destination is taken from: from the socket or given as argument.