socket.connect(port[, address][, callback])
port<integer>address<string>callback<Function> 在连接完成或发生错误时调用。
将 dgram.Socket 连接到远程地址和端口。通过此句柄发送的每条消息都会自动发送到该目标。同时,套接字只会接收来自该远程端的消息。尝试在已连接的套接字上调用 connect() 会导致 ERR_SOCKET_DGRAM_IS_CONNECTED 异常。如果未提供 address,默认将使用 '127.0.0.1'(对于 udp4 套接字)或 '::1'(对于 udp6 套接字)。连接完成后,会触发 'connect' 事件,并调用可选的 callback 函数。如果失败,将调用 callback,如果未提供 callback,则会触发 'error' 事件。
【Associates the dgram.Socket to a remote address and port. Every
message sent by this handle is automatically sent to that destination. Also,
the socket will only receive messages from that remote peer.
Trying to call connect() on an already connected socket will result
in an ERR_SOCKET_DGRAM_IS_CONNECTED exception. If address is not
provided, '127.0.0.1' (for udp4 sockets) or '::1' (for udp6 sockets)
will be used by default. Once the connection is complete, a 'connect' event
is emitted and the optional callback function is called. In case of failure,
the callback is called or, failing this, an 'error' event is emitted.】