Libraries |
|
Socket | Source Code |
|
|
listener
const type: listener
-
Interface type for listeners. The listener interface is implemented with inetListener. A listener manages its accepted sockets.
socket
const type: socket
Function Summary | |||||
socketAddress |
| ||||
socketAddress |
| ||||
file |
| ||||
file |
| ||||
file |
| ||||
void |
| ||||
void |
| ||||
void |
| ||||
void |
| ||||
char |
| ||||
string |
| ||||
string |
| ||||
string |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
|
Function Detail |
localAddress
const func socketAddress: localAddress (in socket: aSocket)
-
Get the local address of the socket 'aSocket'.
- Returns:
- the address to which the socket 'aSocket' is bound.
- Raises:
- FILE_ERROR - A system function returns an error.
- MEMORY_ERROR - Not enough memory to represent the result.
peerAddress
const func socketAddress: peerAddress (in socket: aSocket)
-
Get the address of the peer to which 'aSocket' is connected.
- Returns:
- the address of the peer connected to the socket 'aSocket'.
- Raises:
- FILE_ERROR - A system function returns an error.
- MEMORY_ERROR - Not enough memory to represent the result.
openSocket
const func file: openSocket (in socketAddress: address)
-
Return a connected socket file for the given socket address.
- Returns:
- the socket file opened, or STD_NULL if it could not be opened.
- Raises:
- FILE_ERROR - A system function returns an error.
- MEMORY_ERROR - An out of memory situation occurred.
openInetSocket
const func file: openInetSocket (in integer: portNumber)
-
Return a connected internet socket file at a port at localhost.
- Returns:
- the socket file opened, or STD_NULL if it could not be opened.
- Raises:
- FILE_ERROR - A system function returns an error.
- RANGE_ERROR - The port is not in the range 0 to 65535.
- MEMORY_ERROR - An out of memory situation occurred.
openInetSocket
const func file: openInetSocket (in string: hostName, in integer: portNumber)
-
Return a connected internet socket file at a port at hostName. Here hostName is either a host name (e.g.: "www.example.org"), or an IPv4 address in standard dot notation (e.g.: "192.0.2.235"). Operating systems supporting IPv6 may also accept an IPv6 address in colon notation.
- Returns:
- the socket file opened, or STD_NULL if it could not be opened.
- Raises:
- FILE_ERROR - A system function returns an error.
- RANGE_ERROR - The port is not in the range 0 to 65535.
- MEMORY_ERROR - An out of memory situation occurred.
close
const proc: close (inout socket: aSocket)
-
Close the socket aSocket. A listener manages accepted sockets (its existing connections). When closing a socket, that was accepted from a listener, it is also signed off from the listener.
- Raises:
- FILE_ERROR - A system function returns an error.
flush
const proc: flush (in socket: outSocket)
-
Forces that all buffered data of outSocket is sent to its destination. Flushing a socket has no effect.
write
const proc: write (in socket: outSocket, in string: stri)
-
Write the string stri to outSocket.
- Raises:
- FILE_ERROR - The system function is not able to write all characters of the string.
- RANGE_ERROR - The string contains a character that does not fit into a byte.
writeln
const proc: writeln (in socket: outSocket, in string: stri)
-
Write a string followed by end-of-line to outSocket. This function assures that string and '\n' are sent together.
- Raises:
- FILE_ERROR - The system function is not able to write all characters of the string.
- RANGE_ERROR - The string contains a character that does not fit into a byte.
getc
const func char: getc (inout socket: inSocket)
-
Read a character from inSocket.
- Returns:
- the character read.
gets
const func string: gets (inout socket: inSocket, in integer: maxLength)
-
Read a string with a maximum length from inSocket.
- Returns:
- the string read.
- Raises:
- RANGE_ERROR - The parameter maxLength is negative.
- MEMORY_ERROR - Not enough memory to represent the result.
getwd
const func string: getwd (inout socket: inSocket)
-
Read a word from inSocket. Before reading the word it skips spaces and tabs. The function accepts words ending with " ", "\t", "\n", "\r\n" or EOF. The word ending characters are not copied into the string. That means that the "\r" of a "\r\n" sequence is silently removed. When the function is left the inSocket.bufferChar contains ' ', '\t', '\n' or EOF.
- Returns:
- the word read.
- Raises:
- MEMORY_ERROR - Not enough memory to represent the result.
getln
const func string: getln (inout socket: inSocket)
-
Read a line from 'inSocket'. The function accepts lines ending with "\n", "\r\n" or EOF. The line ending characters are not copied into the string. That means that the "\r" of a "\r\n" sequence is silently removed. When the function is left the inSocket.bufferChar contains '\n' or EOF.
- Returns:
- the line read.
- Raises:
- MEMORY_ERROR - Not enough memory to represent the result.
eof
const func boolean: eof (in socket: inSocket)
-
Determine the end-of-file indicator. The end-of-file indicator is set if at least one request to read from the socket failed. The socket functions getc, gets, getln and getwd indicate the end-of-file situation by setting bufferChar to EOF.
- Returns:
- TRUE if the end-of-file indicator is set, FALSE otherwise.
hasNext
const func boolean: hasNext (in socket: inSocket)
-
Determine if at least one character can be read successfully. This function allows a socket to be handled like an iterator. Since hasNext peeks the next character from the socket it may block.
- Returns:
- FALSE if getc would return EOF, TRUE otherwise.
inputReady
const func boolean: inputReady (in socket: inSocket)
-
Determine if at least one character can be read without blocking. Blocking means that getc would wait until a character is received. Blocking can last for a period of unspecified length.
- Returns:
- TRUE if getc would not block, FALSE otherwise.
|
|