Skip to content

UdpServer

Generic typessource

Requires unsafe mode.

Constructors

function UdpServer.new(host: string, port: integer): UdpServer
host: string
port: integer

Returns UdpServer

function UdpServer.new(address: string): UdpServer
address: string

Returns UdpServer

function UdpServer.new(): UdpServer

Returns UdpServer

Methods

address

function UdpServer:address(): string

Returns string

source

close

function UdpServer:close()
source

is_open

function UdpServer:is_open(): boolean

Returns boolean

source

last_error

function UdpServer:last_error(): integer

Returns integer

source

last_error_str

function UdpServer:last_error_str(): string

Returns string

source

read

function UdpServer:read(fun: function): integer
fun: function
Callback signature not known from the code.

Returns integer

Read message from the socket buffer. Reads maximum of 32KiB at the time. If the message is longer, it will be split to portions of 32KiB. On failure or empty buffer returns -1, on success calls the function with signature nil(message, source)

source

send

function UdpServer:send(message: string, address: string): integer
message: string
address: string

Returns integer

function UdpServer:send(message: string, host: string, port: integer): integer
message: string
host: string
port: integer

Returns integer

source