Skip to content

Search documentation

Enter at least two characters.

    NetworkEndpoint

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

    An address and port describing a local or remote endpoint.

    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.

    Advanced raw networking. Calls that wait for I/O belong in task.spawn/task.defer; normal HTTP apps can use HttpService instead.

    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 Listener = Network:ListenTcp({Address = "loopback", Port = 0})
    task.spawn(function()
    local Peer = Listener:AcceptAsync()
    local Bytes = Peer:ReadExactAsync(4)
    Peer:WriteAsync(Bytes)
    Peer:Close()
    Listener:Close()
    end)
    task.spawn(function()
    local Peer = Network:ConnectTcp({Address = "127.0.0.1", Port = Listener.Port})
    Peer:WriteAsync("ping")
    local Reply = Peer:ReadExactAsync(4)
    Status.Text = buffer.tostring(Reply)
    Peer:Close()
    end)
    Window.Destroying:Connect(function() Listener:Close() end)
    Window.Visible = true

    Expected result: A local TCP client sends four bytes and receives the echo. The fixed four-byte length is this example’s framing rule, not a TCP message boundary.

    Numeric local/remote IP address returned by the socket.

    Type: string. Read-only.

    Local/remote port number.

    Type: number. Read-only.

    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 NetworkEndpoint = {
    read Address: string,
    read Port: 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.