v2026.6.4
All Bundles
Bundle Provides network support

TCPSocket

TCP/IP socket

Operations

Close #

Closes the socket

method : public : Close() ~ Nil

Flush #

Flushes the output buffer. This is a no-opt given this socket is not backed by an output buffer.

method : public : Flush() ~ Nil

GetAddress #

Returns the connected network address

method : public : GetAddress() ~ String

Return

TypeDescription
Stringreturn network address

GetLastError # function

Get the last error

function : GetLastError() ~ String

Return

TypeDescription
Stringlast error message, or Nil of no error

GetPort #

Returns the connected network port

method : public : GetPort() ~ Int

Return

TypeDescription
Intreturn network port

HostName # function

Reads the host name

function : HostName() ~ System.String

Return

TypeDescription
Stringsocket host name

IsOpen #

Returns rather the socket is open

method : public : IsOpen() ~ Bool

Return

TypeDescription
Booltrue if socket is open, false otherwise

New # constructor

Default constructor

New(address:System.String, port:Int)

Parameters

NameTypeDescription
addressStringnetwork address
portIntnetwork port

New # constructor

Constructor with connect timeout

New(address:System.String, port:Int, connect_timeout:Int)

Parameters

NameTypeDescription
addressStringnetwork address
portIntnetwork port
connect_timeoutIntconnect timeout in milliseconds (0 = blocking)

ReadBuffer #

Reads bytes into a byte buffer

method : public : ReadBuffer(offset:Int, num:Int, buffer:Byte[]) ~ Int

Parameters

NameTypeDescription
offsetIntdestination buffer offset
numIntnumber of values to read
bufferByteinput buffer

Return

TypeDescription
Intnumber of values read

ReadBuffer #

Reads bytes into a character buffer

method : public : ReadBuffer(offset:Int, num:Int, buffer:Char[]) ~ Int

Parameters

NameTypeDescription
offsetIntdestination buffer offset
numIntnumber of values to read
bufferCharinput buffer

Return

TypeDescription
Intnumber of values read

ReadByte #

Reads a byte

method : public : ReadByte() ~ Byte

Return

TypeDescription
Bytebyte read

ReadLine #

Reads a string until a newline or character return is detected

method : public : ReadLine() ~ System.String

Return

TypeDescription
Stringcharacter string

Resolve # function

List of resolved IP addresses

function : Resolve(n:System.String) ~ System.String[]

Parameters

NameTypeDescription
nStringaddress name

Return

TypeDescription
Stringlist of IP addresses

Select #

Checks if read/write data is available

method : public : Select(is_write:Bool) ~ Int

Parameters

NameTypeDescription
is_writeBoolif true check for write, otherwise read

Return

TypeDescription
Int1 if ready, 0 if not ready, -1 is error

SetConnectTimeout #

Sets the connect timeout for the next connection attempt. Must be called before New() or before reconnecting.

method : public : SetConnectTimeout(ms:Int) ~ Nil

Parameters

NameTypeDescription
msInttimeout in milliseconds (0 = blocking)

SetKeepAlive #

Sets the TCP keep-alive option

method : public : SetKeepAlive(enable:Bool) ~ Bool

Parameters

NameTypeDescription
enableBooltrue to enable, false to disable

Return

TypeDescription
Booltrue if successful

SetNoDelay #

Disables Nagle's algorithm (TCP_NODELAY) for low-latency sends

method : public : SetNoDelay(enable:Bool) ~ Bool

Parameters

NameTypeDescription
enableBooltrue to disable Nagle, false to re-enable

Return

TypeDescription
Booltrue if successful

SetRecvBufferSize #

Sets the receive buffer size

method : public : SetRecvBufferSize(bytes:Int) ~ Bool

Parameters

NameTypeDescription
bytesIntbuffer size in bytes

Return

TypeDescription
Booltrue if successful

SetRecvTimeout #

Sets the receive timeout

method : public : SetRecvTimeout(ms:Int) ~ Bool

Parameters

NameTypeDescription
msInttimeout in milliseconds

Return

TypeDescription
Booltrue if successful

SetSendBufferSize #

Sets the send buffer size

method : public : SetSendBufferSize(bytes:Int) ~ Bool

Parameters

NameTypeDescription
bytesIntbuffer size in bytes

Return

TypeDescription
Booltrue if successful

SetSendTimeout #

Sets the send timeout

method : public : SetSendTimeout(ms:Int) ~ Bool

Parameters

NameTypeDescription
msInttimeout in milliseconds

Return

TypeDescription
Booltrue if successful

WriteBuffer #

Writes bytes from a byte buffer

method : public : WriteBuffer(buffer:Byte[]) ~ Int

Parameters

NameTypeDescription
bufferByteinput buffer

Return

TypeDescription
Intnumber of values written

WriteBuffer #

Writes bytes from a byte buffer

method : public : WriteBuffer(offset:Int, num:Int, buffer:Byte[]) ~ Int

Parameters

NameTypeDescription
offsetIntdestination buffer offset
numIntnumber of values to write
bufferByteinput buffer

Return

TypeDescription
Intnumber of values written

WriteBuffer #

Writes characters from a byte buffer

method : public : WriteBuffer(buffer:Char[]) ~ Int

Parameters

NameTypeDescription
bufferCharinput buffer

Return

TypeDescription
Intnumber of values written

WriteBuffer #

Writes characters from a character buffer

method : public : WriteBuffer(offset:Int, num:Int, buffer:Char[]) ~ Int

Parameters

NameTypeDescription
offsetIntdestination buffer offset
numIntnumber of values to write
bufferCharinput buffer

Return

TypeDescription
Intnumber of values written

WriteByte #

Writes a byte

method : public : WriteByte(b:Int) ~ Bool

Parameters

NameTypeDescription
bIntbyte to write

Return

TypeDescription
Booltrue if byte was written, false otherwise

WriteString #

Writes a character string

method : public : WriteString(str:System.String) ~ Nil

Parameters

NameTypeDescription
strStringstring to be written