While you can use the connect() call on a datagram socket, it does
not act for a datagram socket as it acts for a stream socket.
On a connect() call, you specify the remote socket address with
which you want to exchange datagrams. This serves the following purposes:
- On succeeding calls to send datagrams, you can use the send()
call without specifying a destination socket address; the datagram
is sent to the socket address you specified on the connnect() call.
- On succeeding calls to receive datagrams, only datagrams that
originate from the socket address specified on the connect() call
are passed to your program from the UDP protocol layer.
Note: A connect() call for a datagram socket does not establish
a connection. No data is exchanged over the IP network as the result
of the connect() call. The functions performed are local, and control
is returned immediately to your application.