Skip to content

Search documentation

Enter at least two characters.

    UdpBindOptions

    SDK 0.1.0-preview.2 · ExperimentalDownload & release notes ↗

    Options used to bind a UDP socket and bound its datagrams.

    Advanced app/host integration API. Useful for lower-level work; ordinary app authors can start with the app-building path. This is public API, not permission to access private toolkit objects.

    Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.

    Project setup: add network.raw, network.client, network.server to Capabilities in lui.json. See the capability guide.

    local Window = Instance.new("Window", {
    Title = "LUI example", Size = UDim2.fromOffset(560, 280),
    })
    local Status = Instance.new("TextLabel", {
    Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 170),
    Size = UDim2.new(1, -32, 0, 72),
    })
    local Network = app:GetService("NetworkService")
    local Receiver = Network:BindUdp({Address = "loopback", Port = 0, MaxDatagramBytes = 1024})
    local Sender = Network:BindUdp({Address = "loopback", Port = 0, MaxDatagramBytes = 1024})
    task.spawn(function()
    local Packet = Receiver:ReceiveFromAsync()
    Status.Text = buffer.tostring(Packet.Data) .. " from " .. Packet.RemoteEndpoint.Address
    Receiver:Close()
    end)
    task.spawn(function()
    Sender:SendToAsync(Receiver.LocalEndpoint, "Hello UDP")
    Sender:Close()
    end)
    Window.Destroying:Connect(function() Receiver:Close(); Sender:Close() end)
    Window.Visible = true

    Expected result: Sends one local datagram and displays its bytes and sender. UDP delivery is not guaranteed outside this demonstration.

    Local bind address; loopback keeps traffic on this machine.

    Type: string?. Read/write field.

    IPv4 or IPv6. UDP has no DualStack option in this profile.

    Type: ("IPv4" \| "IPv6")?. Read/write field.

    Local port; 0 requests a free port if allowed by policy.

    Type: number. Read/write field.

    Maximum accepted datagram size, in bytes. A datagram is one UDP packet payload, unlike a TCP byte stream.

    Type: number?. Read/write field.

    Full type declaration — for type checking and deeper reference

    The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.

    export type UdpBindOptions = {
    Address: string?,
    Family: ("IPv4" | "IPv6")?,
    Port: number,
    MaxDatagramBytes: number?,
    }

    See platform limits before relying on host-specific behavior. The framework design specification and reflection/type sources are deeper engineering references, not extra setup required to build an app.