Libraries
Sockbase Source Code
 previous   up   next 

Types
socketAddress
Abstract data type to store socket addresses.

socketAddress

const type: socketAddress

Abstract data type to store socket addresses.


Function Summary
integer
compare (in socketAddress: addr1, in socketAddress: addr2)
Compare two socket addresses.
integer
hashCode (in socketAddress: address)
Compute the hash value of a socket address.
string
numericAddress (in socketAddress: address)
Get the numeric (IP) address of the host at address.
socketAddress
inetSocketAddress (in string: hostName, in integer: port)
Create an internet socket address of a port at a host.
socketAddress
inetSocketAddress (in integer: port)
Create an internet socket address of a port at localhost.
socketAddress
inetListenerAddress (in integer: port)
Create an internet listener socket address of a port at localhost.
string
getHostname
Determine the hostname.
void
connect (in PRIMITIVE_SOCKET: aSocket, in socketAddress: address)
Connect aSocket to the given address.
PRIMITIVE_SOCKET
accept (in PRIMITIVE_SOCKET: listenerSocket, inout socketAddress: address)
Create a new accepted connection socket for listenerSocket.
void
bind (in PRIMITIVE_SOCKET: listenerSocket, in socketAddress: address)
Assign the specified address to the listenerSocket.
void
listen (in PRIMITIVE_SOCKET: listenerSocket, in integer: backlog)
Listen for socket connections and limit the incoming queue.

Function Detail

compare

const func integer: compare (in socketAddress: addr1, in socketAddress: addr2)

Compare two socket addresses.

Returns:
-1, 0 or 1 if the first argument is considered to be respectively less than, equal to, or greater than the second.

hashCode

const func integer: hashCode (in socketAddress: address)

Compute the hash value of a socket address.

Returns:
the hash value.

numericAddress

const func string: numericAddress (in socketAddress: address)

Get the numeric (IP) address of the host at address. IPv4 addresses return the socketAddress in dot notation (e.g.: "192.0.2.235") and IPv6 addresses return the socketAddress in colon notation (e.g.: "fe80:0:0:0:202:b3ff:fe1e:8329").

Returns:
the IP address of the specified host.
Raises:
RANGE_ERROR - The address is neither AF_INET nor AF_INET6.

inetSocketAddress

const func socketAddress: inetSocketAddress (in string: hostName, in integer: port)

Create an internet socket address of a port at a host. The 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 internet socket address, and socketAddress.value if the host cannot be found.
Raises:
FILE_ERROR - A system function returns an error.
RANGE_ERROR - The port is not in the range 0 to 65535 or hostName cannot be converted to the system string type.
MEMORY_ERROR - Not enough memory to convert hostName. to the system representation or not enough memory to represent the result.

inetSocketAddress

const func socketAddress: inetSocketAddress (in integer: port)

Create an internet socket address of a port at localhost.

Returns:
the internet socket address.
Raises:
FILE_ERROR - A system function returns an error.
RANGE_ERROR - The port is not in the range 0 to 65535.
MEMORY_ERROR - Not enough memory to represent the result.

inetListenerAddress

const func socketAddress: inetListenerAddress (in integer: port)

Create an internet listener socket address of a port at localhost.

Returns:
the internet listener socket address.
Raises:
FILE_ERROR - A system function returns an error.
RANGE_ERROR - The port is not in the range 0 to 65535.
MEMORY_ERROR - Not enough memory to represent the result.

getHostname

const func string: getHostname

Determine the hostname.

Returns:
the hostname.
Raises:
MEMORY_ERROR - Not enough memory to represent the result.

connect

const proc: connect (in PRIMITIVE_SOCKET: aSocket, in socketAddress: address)

Connect aSocket to the given address.

Raises:
FILE_ERROR - A system function returns an error.

accept

const func PRIMITIVE_SOCKET: accept (in PRIMITIVE_SOCKET: listenerSocket, inout socketAddress: address)

Create a new accepted connection socket for listenerSocket. The function waits until at least one connection request is in the sockets queue of pending connections. Then it extracts the first connection request from the sockets queue. This request is accepted and a connection socket is created for it.

Returns:
the accepted connection socket.
Raises:
FILE_ERROR - A system function returns an error.
MEMORY_ERROR - An out of memory situation occurred.

bind

const proc: bind (in PRIMITIVE_SOCKET: listenerSocket, in socketAddress: address)

Assign the specified address to the listenerSocket.

Parameters:
address - An internet listener socket address.
Raises:
FILE_ERROR - A system function returns an error.

listen

const proc: listen (in PRIMITIVE_SOCKET: listenerSocket, in integer: backlog)

Listen for socket connections and limit the incoming queue. The backlog argument defines the maximum length to which the queue of pending connections for listenerSocket may grow.

Raises:
FILE_ERROR - A system function returns an error.


 previous   up   next