ReadonlyidentifierA unique identifier for this socket (UUID string).
ReadonlyisWhether the socket has been bound to a path with bind().
ReadonlyisWhether the socket is connected to a single peer with connect().
ReadonlyisWhether the socket is currently receiving datagrams.
ReadonlylocalThe path the socket is bound to, or null if it isn't bound.
ReadonlypeerThe path of the peer the socket is connected to, or null if it isn't connected.
Binds the socket to a path, creating a socket file there that other programs can send
datagrams to. Call it before connect() or sending.
A stale socket file left at the path by a socket that has gone is replaced, but binding
fails if another socket is still using it. close() removes the socket file.
The path to create the socket file at, at most 103 bytes long, e.g. "/tmp/hammerspoon.sock".
The socket, for chaining.
Closes the socket immediately, and removes its socket file if it's bound. 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 path, and only
datagrams from that peer are received. The callback receives "connected" straight away.
The path of the peer's socket file.
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 be bound 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.
Optionalpath: string | null
The path of the socket file 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.
Optionalpath: string | null
The path of the socket file to send to. Omit it if the socket is connected.
The socket, for chaining.
Sets the callback that receives this socket's events.
The callback receives the event name, the socket, and event-specific arguments:
"data" - a datagram arrived; the third argument is a Uint8Array and the fourth is the
sender's address, as {path}, or null if the sender's socket isn't bound to a path
(so it can't be replied to)."connected" - connect() succeeded; the fourth argument is the peer's address."error" - something went wrong; the third argument is a description.The event handler, or null to remove it.
The socket, for chaining.
A Unix domain datagram socket, created by
hs.socket.createUnixDatagram().A Unix domain datagram socket exchanges messages with other programs on this Mac through a socket file. Each message arrives whole, as one
"data"event. Other programs can only send to it once it has been bound to a path withbind(), which creates the socket file there.This is what tools such as Karabiner-Elements'
send_user_commandsend to.Do not instantiate
HSUnixDatagramSocketdirectly - usehs.socket.createUnixDatagram().