Provides network support
UDPSocket
UDP/IP socket
Operations
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
Gets the calling thread's last socket failure: why its latest call on a socket -- connect, read, write, bind, listen, accept, a socket option -- failed, captured as it failed. Each such call replaces it, one that works leaves none, and closing the socket keeps it. A connect that tried several addresses gives the most informative reason: one the network answered (refused, reset, timed out) over one that never left this host. A name that does not resolve gives the resolver's reason.
function : GetLastError() ~ StringReturn
| Type | Description |
|---|---|
| String | last error message, or Nil if the calling thread's latest socket call worked |
GetPort #
Returns the connected network port
method : public : GetPort() ~ IntReturn
| Type | Description |
|---|---|
| Int | return network port |
New # constructor
A socket connected to one peer: it sends datagrams to the peer and reads the peer's. The address is a host name or an IPv4 or IPv6 literal, resolved as TCPSocket->New resolves it, and a name can resolve to several addresses ("localhost" is ::1 and 127.0.0.1). The socket starts with the first; when the network answers that nobody listens there (an ICMP port unreachable for an earlier datagram), it moves on to the next, so it reaches a server listening on either. When every address has refused, the read or write that found out fails and GetLastError() says "Connection refused". If the name cannot be resolved, GetLastError() says why and the socket sends nothing.
New(address:System.String, port:Int)Parameters
| Name | Type | Description |
|---|---|---|
| address | String | network address |
| port | Int | network port |
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 |
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 |