Skip to content

Net

Net . urlEncode ( url ,  binary )  -> string

Encodes the given string using URL encoding.

Parameters

url: string
binary: boolean?

Returns

string
Net . request ( config )  -> FetchResponse

Sends an HTTP request using the given url and / or parameters, and returns a dictionary that describes the response received.

Only throws an error if a miscellaneous network or I/O error occurs, never for unsuccessful status codes.

Parameters

config: string | FetchParams

Returns

FetchResponse
Net . tcpSocket ( url )  -> WebSocket

Connects to a TCP web socket at the given URL.

next() waits for the next message and returns its text, or nil once the socket has closed. nextMessage() does the same and also returns whether the message arrived as a binary frame; on runtimes whose sockets do not say, that flag is nil.

Throws an error if the server at the given URL does not support web sockets, or if a miscellaneous network or I/O error occurs.

Parameters

url: string

Returns

WebSocket
Net . udpSocket ( host ,  port )  -> UdpSocket

Connects to a UDP web socket at the given URL.

Throws an error if the server at the given URL does not support web sockets, or if a miscellaneous network or I/O error occurs.

Parameters

host: string
port: number

Returns

UdpSocket