创建socket的地方用SOCK_DGRAM UDP可以使用connect函数。如果使用connect以后,下面的发送和接收就可以用send/recv,而不是非得用sendto/recvfrom了,因为connect的时候就指定了IP和PORT等相关信息了。 For a connectionless socket (for example, type SOCK_DGRAM), the operation performed by connect is merely to establish a default destination address that can be used on subsequent send/WSASend and recv/WSARecv calls.
UDP可以使用connect函数。如果使用connect以后,下面的发送和接收就可以用send/recv,而不是非得用sendto/recvfrom了,因为connect的时候就指定了IP和PORT等相关信息了。
For a connectionless socket (for example, type SOCK_DGRAM), the operation performed by connect is merely to establish a default destination address that can be used on subsequent send/WSASend and recv/WSARecv calls.