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


Ulm's Oberon Library:
IPv4TCPSockets


NAME

IPv4TCPSockets - create and access IPv4 TCP sockets

SYNOPSIS

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


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

IPv4TCPSockets provides a stream interface for IPv4 TCP domain sockets. InetTCP bases on IPv4TCPSockets and provides an interface which conforms to Networks. IPv4TCPSockets itself uses the generic stream interface for sockets of UnixSockets.

Open tries to create a socket which is connected to the given IPv4 address. IPv4 addresses consist of a 4-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 IPv4 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
InetTCP
offers IPv4 TCP domain sockets for Networks
IPv4Addresses
support of IPv4 addresses
Networks
general abstraction for network connections
RelatedEvents
handling of error events
InetResolver
conversion of domain style addresses to IPv4 addresses
Streams
stream operations
UnixSockets
generic stream interface of sockets

Edited by: borchert, last change: 2005/01/21, revision: 1.12, converted to HTML: 2005/01/21

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