udp
UDP datagram sockets.
Import
ts
import { Udp } from "udp";Needs the "net" permission in thicket.json.
UdpSender class
ts
class UdpSenderType only: the runtime hands you instances; you never construct it yourself.
Sender address supplied to UDP receive callbacks.
UdpSender.host
ts
readonly host: stringHost address (IP) of the sender.
UdpSender.port
ts
readonly port: intPort number of the sender.
UdpSocket class
ts
class UdpSocketType only: the runtime hands you instances; you never construct it yourself.
A bound or unbound UDP socket.
UdpSocket.sendTo
ts
sendTo(host: string, port: int, data: string | ByteArray): voidSend a datagram to a remote address.
Parameters
host: Destination host (IP address).port: Destination port (1–65535).data: Payload as string or ByteArray.
UdpSocket.onData
ts
onData(fn: (data: string, sender: UdpSender) => void): voidRegister a callback to receive datagrams as strings.
Parameters
fn: Callback receiving(data: string, sender: UdpSender).
UdpSocket.onBinary
ts
onBinary(fn: (data: ByteArray, sender: UdpSender) => void): voidRegister a callback to receive datagrams as ByteArray.
Parameters
fn: Callback receiving(data: ByteArray, sender: UdpSender).
UdpSocket.port
ts
readonly port: intLocal port this socket is bound to. Read-only.
UdpSocket.broadcast
ts
broadcast: booleanEnable or disable broadcast mode.
UdpSocket.close
ts
close(): voidClose the socket and stop listening.
Udp static class
ts
static class UdpUDP socket factories.
Udp.bind
ts
static bind(port: int, host?: string): UdpSocketCreate and bind a UDP socket to a local address.
Parameters
port: Local port to bind to; 0 means the OS assigns an available port.host: Local host/interface to bind to; defaults to all interfaces.
Returns: A bound UdpSocket.
Udp.create
ts
static create(): UdpSocketCreate an unbound UDP socket for outbound-only use or later binding.
Returns: An unbound UdpSocket.
Generated from lang/types/udp.d.tks in the ThicketScript repository.