dgram.createSocket(type[, callback])


创建一个指定 typedgram.Socket 对象。

【Creates a dgram.Socket object of the specified type.】

一旦套接字被创建,调用 socket.bind() 将指示套接字开始监听数据报消息。当 addressport 未传递给 socket.bind() 时,该方法将把套接字绑定到一个随机端口的“所有接口”地址(对于 udp4udp6 套接字都能正确处理)。绑定的地址和端口可以通过 socket.address().addresssocket.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.】