dgram.createSocket(type[, callback])
type<string> 可以是'udp4'或'udp6'。callback<Function> 作为监听器附加到'message'事件。- 返回: <dgram.Socket>
创建一个指定 type 的 dgram.Socket 对象。
【Creates a dgram.Socket object of the specified type.】
一旦套接字被创建,调用 socket.bind() 将指示套接字开始监听数据报消息。当 address 和 port 未传递给 socket.bind() 时,该方法将把套接字绑定到一个随机端口的“所有接口”地址(对于 udp4 和 udp6 套接字都能正确处理)。绑定的地址和端口可以通过 socket.address().address 和 socket.address().port 获取。
【Once the socket is created, calling socket.bind() will instruct the
socket to begin listening for datagram messages. When address and port are
not passed to socket.bind() the method will bind the socket to the "all
interfaces" address on a random port (it does the right thing for both udp4
and udp6 sockets). The bound address and port can be retrieved using
socket.address().address and socket.address().port.】