Whether the socket may send to broadcast addresses (e.g. 255.255.255.255). Defaults to
false. Broadcasts are IPv4 only.
ReadonlyidentifierA unique identifier for this socket (UUID string).
Whether the socket uses IPv4. Defaults to true. Set it before the socket binds,
connects or sends.
Whether the socket uses IPv6. Defaults to true. Set it before the socket binds,
connects or sends.
ReadonlyisWhether the socket has been bound to a local port with bind().
ReadonlyisWhether the socket is connected to a single peer with connect().
ReadonlyisWhether the socket is currently receiving datagrams.
ReadonlylocalThe local port the socket is using, or 0 if it doesn't have one yet.
Whether other sockets may bind to the same port, e.g. so several programs can receive the
same broadcasts. Defaults to false. Set it before calling bind().
Binds the socket to a local port, so it can receive datagrams sent to that port. Call it
before connect() or sending.
By default the socket binds on all network interfaces. Pass one of this Mac's IP addresses
to bind only to that address (and so only to the interface that has it). Use
hs.network.addresses() to find an interface's addresses.
If the interface's address can change (e.g. it comes from DHCP), watch
State:/Network/Interface/<name>/IPv4 with hs.network.configurationWatcher() and bind again
when it does.
The UDP port to bind to, or 0 to let the system choose one (see localPort).
Optionaladdress: string | nullA local IPv4 or IPv6 address to bind to, e.g. "127.0.0.1" or "192.168.1.20". Defaults to all addresses.
The socket, for chaining.
Closes the socket immediately, discarding any sends still waiting for a host lookup. The socket can be bound, connected or used to send again afterwards.
The socket, for chaining.
Connects the socket to a single peer. Afterwards, send() needs no host and port, and only
datagrams from that peer are received. The callback receives "connected" once the host
has been looked up.
The host name or IP address of the peer.
The peer's UDP port.
The socket, for chaining.
Closes the socket and releases its callback.
Stops receiving datagrams. Datagrams that arrive meanwhile are queued by the system (up to its buffer size) and delivered once you receive again.
The socket, for chaining.
Starts delivering every datagram that arrives to the callback, until pause() or
close(). The socket must have a local port first (see bind()).
The socket, for chaining.
Delivers the next datagram that arrives to the callback, then stops receiving.
The socket, for chaining.
Sends text, encoded as UTF-8, as one datagram.
The text to send.
Optionalhost: string | nullThe host name or IP address to send to. Omit it if the socket is connected.
Optionalport: numberThe UDP port to send to. Omit it if the socket is connected.
The socket, for chaining.
Sends raw bytes as one datagram.
The bytes to send. Any typed array is accepted.
Optionalhost: string | nullThe host name or IP address to send to. Omit it if the socket is connected.
Optionalport: numberThe UDP port to send to. Omit it if the socket is connected.
The socket, for chaining.
Sets the callback that receives this socket's events.
sender's address, as {host, port, family}, where family is "ipv4" or "ipv6".
The event handler, or null to remove it.
The socket, for chaining.
A UDP socket, created by
hs.socket.createUDP(). A UDP socket can send datagrams to any host, or be connected to a single peer, and can receive datagrams once it has a local port: either one chosen withbind(), or one the system assigns when it first connects or sends. IPv4 and IPv6 are both supported, using a separate system socket for each. Do not instantiateHSUDPSocketdirectly - usehs.socket.createUDP().