TCPSocket
TCP/IP socket
Operations
- New
- Close
- Flush
- GetAddress
- GetLastError
- GetPort
- HostName
- IsOpen
- ReadBuffer
- ReadByte
- ReadLine
- Resolve
- Select
- SetConnectTimeout
- SetKeepAlive
- SetNoDelay
- SetRecvBufferSize
- SetRecvTimeout
- SetSendBufferSize
- SetSendTimeout
- WriteBuffer
- WriteByte
- WriteString
Flush #
Flushes the output buffer. This is a no-opt given this socket is not backed by an output buffer.
method : public : Flush() ~ NilGetAddress #
Returns the connected network address
method : public : GetAddress() ~ StringReturn
| Type | Description |
|---|---|
| String | return network address |
GetLastError # function
Get the last error
function : GetLastError() ~ StringReturn
| Type | Description |
|---|---|
| String | last error message, or Nil of no error |
GetPort #
Returns the connected network port
method : public : GetPort() ~ IntReturn
| Type | Description |
|---|---|
| Int | return network port |
HostName # function
Reads the host name
function : HostName() ~ System.StringReturn
| Type | Description |
|---|---|
| String | socket host name |
IsOpen #
Returns rather the socket is open
method : public : IsOpen() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if socket is open, false otherwise |
New # constructor
Default constructor
New(address:System.String, port:Int)Parameters
| Name | Type | Description |
|---|---|---|
| address | String | network address |
| port | Int | network port |
New # constructor
Constructor with connect timeout
New(address:System.String, port:Int, connect_timeout:Int)Parameters
| Name | Type | Description |
|---|---|---|
| address | String | network address |
| port | Int | network port |
| connect_timeout | Int | connect timeout in milliseconds (0 = blocking) |
ReadBuffer #
Reads bytes into a byte buffer
method : public : ReadBuffer(offset:Int, num:Int, buffer:Byte[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | destination buffer offset |
| num | Int | number of values to read |
| buffer | Byte | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values read |
ReadBuffer #
Reads bytes into a character buffer
method : public : ReadBuffer(offset:Int, num:Int, buffer:Char[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | destination buffer offset |
| num | Int | number of values to read |
| buffer | Char | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values read |
ReadLine #
Reads a string until a newline or character return is detected
method : public : ReadLine() ~ System.StringReturn
| Type | Description |
|---|---|
| String | character string |
Resolve # function
List of resolved IP addresses
function : Resolve(n:System.String) ~ System.String[]Parameters
| Name | Type | Description |
|---|---|---|
| n | String | address name |
Return
| Type | Description |
|---|---|
| String | list of IP addresses |
Select #
Checks if read/write data is available
method : public : Select(is_write:Bool) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| is_write | Bool | if true check for write, otherwise read |
Return
| Type | Description |
|---|---|
| Int | 1 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) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| ms | Int | timeout in milliseconds (0 = blocking) |
SetKeepAlive #
Sets the TCP keep-alive option
method : public : SetKeepAlive(enable:Bool) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| enable | Bool | true to enable, false to disable |
Return
| Type | Description |
|---|---|
| Bool | true if successful |
SetNoDelay #
Disables Nagle's algorithm (TCP_NODELAY) for low-latency sends
method : public : SetNoDelay(enable:Bool) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| enable | Bool | true to disable Nagle, false to re-enable |
Return
| Type | Description |
|---|---|
| Bool | true if successful |
SetRecvBufferSize #
Sets the receive buffer size
method : public : SetRecvBufferSize(bytes:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| bytes | Int | buffer size in bytes |
Return
| Type | Description |
|---|---|
| Bool | true if successful |
SetRecvTimeout #
Sets the receive timeout
method : public : SetRecvTimeout(ms:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| ms | Int | timeout in milliseconds |
Return
| Type | Description |
|---|---|
| Bool | true if successful |
SetSendBufferSize #
Sets the send buffer size
method : public : SetSendBufferSize(bytes:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| bytes | Int | buffer size in bytes |
Return
| Type | Description |
|---|---|
| Bool | true if successful |
SetSendTimeout #
Sets the send timeout
method : public : SetSendTimeout(ms:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| ms | Int | timeout in milliseconds |
Return
| Type | Description |
|---|---|
| Bool | true if successful |
WriteBuffer #
Writes bytes from a byte buffer
method : public : WriteBuffer(buffer:Byte[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| buffer | Byte | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values written |
WriteBuffer #
Writes bytes from a byte buffer
method : public : WriteBuffer(offset:Int, num:Int, buffer:Byte[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | destination buffer offset |
| num | Int | number of values to write |
| buffer | Byte | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values written |
WriteBuffer #
Writes characters from a byte buffer
method : public : WriteBuffer(buffer:Char[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| buffer | Char | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values written |
WriteBuffer #
Writes characters from a character buffer
method : public : WriteBuffer(offset:Int, num:Int, buffer:Char[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | destination buffer offset |
| num | Int | number of values to write |
| buffer | Char | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values written |