LIBSOCK(3)

NAME
socket.accept, socket.bind, socket.close, socket.connect, socket.create, socket.error, socket.fullread, socket.fullwrite, socket.fullwrite.addr, socket.listen, socket.read, socket.recvfrom, socket.sendto, socket.shutdown, socket.write, socket.write.addr, socket.getdomainname, socket.gethostname, socket.getpeername, socket.getsockname, socket.getsockopt, socket.setdomainname, socket.sethostname, socket.setsockopt, socket.addr.of.host, socket.addrs.of.host, socket.host.of.addr, socket.ip.of.addr, socket.naddrs.of.host, socket.create.connect.tcp, socket.create.listen.tcp, socket.create.listen.udp, socket.create.tcp, socket.create.udp, socket.altable.accept, socket.altable.fullread, socket.altable.fullwrite, socket.altable.read, socket.altable.write - KRoC socket library

SYNOPSIS
#INCLUDE "sock.module"

PROC socket.accept (SOCKET sock, RESULT SOCKET client, RESULT INT result)
PROC socket.bind (SOCKET sock, RESULT INT result)
PROC socket.close (SOCKET sock)
PROC socket.connect (SOCKET sock, RESULT INT result)
PROC socket.create (RESULT SOCKET sock, VAL INT domain, VAL INT type, VAL INT protocol)
PROC socket.error (SOCKET sock, []BYTE buffer, RESULT INT length)
PROC socket.fullread (SOCKET sock, []BYTE buffer, VAL INT count, RESULT INT result)
PROC socket.fullwrite (SOCKET sock, VAL []BYTE buffer, RESULT INT result)
PROC socket.fullwrite.addr (SOCKET sock, VAL INT addr, size, INT result)
PROC socket.listen (SOCKET sock, VAL INT backlog, RESULT INT result)
PROC socket.read (SOCKET sock, []BYTE buffer, VAL INT count, RESULT INT result)
PROC socket.recvfrom (SOCKET sock, []BYTE message, VAL INT flags, RESULT INT result)
PROC socket.sendto (SOCKET sock, VAL []BYTE message, VAL INT flags, RESULT INT result)
PROC socket.shutdown (SOCKET sock, VAL INT how, RESULT INT result)
PROC socket.write (SOCKET sock, VAL []BYTE buffer, RESULT INT result)
PROC socket.write.addr (SOCKET sock, VAL INT addr, size, INT result)

PROC socket.getdomainname (RESULT []BYTE name, RESULT INT result)
PROC socket.gethostname (RESULT []BYTE name, RESULT INT result)
PROC socket.getpeername (SOCKET sock, RESULT INT result)
PROC socket.getsockname (SOCKET sock, RESULT INT result)
PROC socket.getsockopt (SOCKET sock, VAL INT level, VAL INT option, RESULT INT value, RESULT INT result)
PROC socket.setdomainname (VAL []BYTE name, RESULT INT result)
PROC socket.sethostname (VAL []BYTE name, RESULT INT result)
PROC socket.setsockopt (SOCKET sock, VAL INT level, VAL INT option, VAL INT value, RESULT INT result)

PROC socket.addr.of.host (VAL []BYTE hostname, RESULT INT addr, RESULT INT result)
PROC socket.addrs.of.host (VAL []BYTE hostname, RESULT []INT addrs, RESULT INT result)
PROC socket.host.of.addr (VAL INT addr, []BYTE hostname, INT length, INT result)
PROC socket.ip.of.addr (VAL INT addr, []BYTE ip.addr, INT length, INT result)
PROC socket.naddrs.of.host (VAL []BYTE hostname, RESULT INT result)

PROC socket.create.connect.tcp (SOCKET sock, VAL INT addr, VAL INT port, INT result)
PROC socket.create.listen.tcp (SOCKET sock, VAL INT addr, VAL INT port, INT result)
PROC socket.create.listen.udp (SOCKET sock, VAL INT addr, VAL INT port, INT result)
PROC socket.create.tcp (SOCKET sock)
PROC socket.create.udp (SOCKET sock)

PROC socket.altable.accept (CHAN OF BOOL kill, CHAN OF INT response, SOCKET sock, SOCKET client, INT result)
PROC socket.altable.fullread (CHAN OF BOOL kill, CHAN OF INT response, SOCKET sock, []BYTE buffer, VAL INT count, INT result)
PROC socket.altable.fullwrite (CHAN OF BOOL kill, CHAN OF INT response, SOCKET sock, VAL []BYTE buffer, INT result)
PROC socket.altable.read (CHAN OF BOOL kill, CHAN OF INT response, SOCKET sock, []BYTE buffer, VAL INT count, INT result)
PROC socket.altable.recvfrom (CHAN OF BOOL kill, CHAN OF INT response, SOCKET sock, []BYTE message, VAL INT flags, INT result)
PROC socket.altable.write (CHAN OF BOOL kill, CHAN OF INT response, SOCKET sock, VAL []BYTE buffer, INT result)

DESCRIPTION
The occam socket library uses the blocking system call functionality within KRoC to allow socket operations to be performed asynchronously. A rich set of occam PROCs provide most of the socket functionality, as is available from the C world.

The following structure shows the information kept about a socket:
DATA TYPE SOCKET
PACKED RECORD
INT fd:
INT local.port:
INT remote.port:
INT local.addr:
INT remote.addr:
INT s.family:
INT s.type:
INT s.proto:
INT error:
:

For a given .SOCKET s:

s[fd] is the file-descritor of the socket. s[local.port] and s[remote.port] are the port numbers of the local and remote ends of the socket. s[local.addr] and s[remote.addr] are the addresses. These are stored as host-ordered `packed' IP addresses. s[s.family] is the socket family used for this socket. Most of the time, this will be PF.INET, specifying a normal network socket. s[s.type] specifies the socket type. The two common ones are stream based sockets, specified with SOCK.STREAM, and datagram based sockets, specified with SOCK.DGRAM. s[s.proto] specifies the protocol which is being used. More often than not, this depends on the socket type. IPPROTO.TCP is normally specified for SOCK.STREAM sockets, and IPPROTO.UDP for SOCK.DGRAM sockets. s[error] contains the error code of the last operation on this socket, if it failed.

This structure does not accurately reflect the true types of the two `port' and `addr' fields. Ports are typically unsigned 16-bit numbers, while addresses are unsigned 32-bit numbers (for IPV4 at least). They are incorrect for ease of compatability with the corresponding structure in the C code, in addition, occam does not provide unsigned 16-bit or 32-bit types.

AUTHOR
This manual page is maintained by Fred Barnes <frmb@kent.ac.uk>

SEE ALSO
kroc(1)
doc/bsclib.ps, doc/bsclib/index.html in the KRoC distribution