Package-level declarations

Types

Link copied to clipboard
sealed external interface BindOptions
Link copied to clipboard
sealed external interface RemoteInfo
Link copied to clipboard
sealed external interface RemoteInfoFamily
Link copied to clipboard
external class Socket : EventEmitter

Encapsulates the datagram functionality.

Link copied to clipboard
sealed external interface SocketOptions : Abortable
Link copied to clipboard
sealed external interface SocketType

Functions

Link copied to clipboard
external fun createSocket(options: SocketOptions, callback: (msg: Buffer, rinfo: RemoteInfo) -> Unit = definedExternally): Socket

external fun createSocket(type: SocketType, callback: (msg: Buffer, rinfo: RemoteInfo) -> Unit = definedExternally): Socket

Creates a dgram.Socket object. 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.