Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
IPv6TCPSockets


NAME

IPv6TCPSockets - create and access IPv6 TCP sockets

SYNOPSIS

TYPE Socket = UnixSockets.Socket;
TYPE Address = IPv6Addresses.Address;
TYPE SocketAddress = IPv6Addresses.SocketAddress;


CONST openFailed = 0; CONST listenFailed = 1; CONST errors = 2; TYPE ErrorCode = SHORTINT; (* openFailed .. *) TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) address: SocketAddress; errorcode: ErrorCode; END; VAR error: Events.EventType; VAR errormsg: ARRAY errors OF Events.Message;

PROCEDURE Open(VAR s: Streams.Stream; address: SocketAddress; bufmode: Streams.BufMode; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE OpenAs(VAR s: Streams.Stream; address, bindto: SocketAddress; bufmode: Streams.BufMode; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE CreateOpenCondition(VAR condition: Conditions.Condition; address: SocketAddress); PROCEDURE CreateOpenConditionAs(VAR condition: Conditions.Condition; address, bindto: SocketAddress); PROCEDURE TestAndOpen(VAR s: Streams.Stream; condition: Conditions.Condition; bufmode: Streams.BufMode; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Drop(condition: Conditions.Condition);

PROCEDURE CreateSomeSocket(VAR socket: Socket; VAR address: SocketAddress; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE CreateSomeSocketOn(VAR socket: Socket; VAR address: SocketAddress; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Listen(VAR socket: Socket; portnum: INTEGER; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE ListenOn(VAR socket: Socket; address: SocketAddress; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Accept(socket: Socket; VAR s: Streams.Stream; bufmode: Streams.BufMode; VAR peer: SocketAddress) : BOOLEAN; PROCEDURE Release(socket: Socket);

PROCEDURE CreateAcceptCondition(VAR condition: Conditions.Condition; socket: Socket);

PROCEDURE GetName(socket: Socket; VAR address: SocketAddress; errors: RelatedEvents.Object) : BOOLEAN;

DESCRIPTION

IPv6TCPSockets provides a stream interface for IPv6 TCP domain sockets. Inet6TCP bases on IPv6TCPSockets and provides an interface which conforms to Networks. IPv6TCPSockets itself uses the generic stream interface for sockets of UnixSockets.

Open tries to create a socket which is connected to the given IPv6 address. IPv6 addresses consist of a 16-byte address which identifies the host and a 2-byte integer which identifies the communication partner on that machine.

OpenAs works like Open but allows in bindto a local IP address to be specified the socket is to be bound to locally. This is useful in case of virtual IP addresses.

CreateOpenCondition and TestAndOpen may be used like their counterparts of Networks for non-blocking openings. CreateOpenConditionAs works like CreateOpenCondition but allows in bindto a local IP address to be specified (see OpenAs). Drop may be used to get rid of conditions created by CreateOpenCondition or CreateOpenConditionAs which have not yet been successfully opened using TestAndOpen.

Listen creates a socket which may be later used to wait for incoming connections. Each socket is uniquely identified by a port number on the current machine. ListenOn works like Listen but allows a full IPv6 address to specified (mainly for virtual IP addresses).

CreateSomeSocket and CreateSomeSocketOn operate like Listen and ListenOn but leave the selection of the port number up to the system. Note that address is an out-parameter only for CreateSomeSocket while CreateSomeSocketOn honors the host part of address. Release allows to release a socket which has been formerly created by Listen. Accept waits for incoming connections for socket. The socket must have been created and prepared by Listen, ListenOn, CreateSomeSocket, or CreateSomeSocketOn. The resulting stream s is connected with the new communication partner. The address of the other side is stored into peer.

CreateAcceptCondition creates a condition which evaluates to TRUE if a subsequent Accept would not block for socket.

GetName returns the address of a socket. This is particularly useful when a port number of 0 has been given to Listen in order to delegate the choice to the system.

DIAGNOSTICS

All procedures return FALSE and relate their error events to errors in case of errors.

Errors are converted into events of RelatedEvents. Accept relates its errors to socket. By default, these events are being queued.

SEE ALSO

Conditions
interface for conditions
Inet6TCP
offers IPv6 TCP domain sockets for Networks
IPv6Addresses
support of IPv6 addresses
Networks
general abstraction for network connections
RelatedEvents
handling of error events
InetResolver
conversion of domain style addresses to IPv6 addresses
Streams
stream operations
UnixSockets
generic stream interface of sockets

Edited by: borchert, last change: 2006/08/09, revision: 1.1, converted to HTML: 2006/08/09

Oberon || Library || Module Index || Search Engine || Definition || Module