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

Ulm's Oberon Library:


UnixDomainSockets - create and access UNIX domain sockets


TYPE Socket = POINTER TO SocketRec;
TYPE SocketRec = RECORD (UnixSockets.SocketRec) END;

PROCEDURE Open(VAR s: Streams.Stream; pathname: ARRAY OF CHAR; bufmode: Streams.BufMode; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE CreateOpenCondition(VAR condition: Conditions.Condition; pathname: ARRAY OF CHAR); PROCEDURE TestAndOpen(VAR s: Streams.Stream; condition: Conditions.Condition; bufmode: Streams.BufMode; errors: RelatedEvents.Object) : BOOLEAN;

PROCEDURE CreateSomeSocket(VAR socket: Socket; VAR pathname: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Listen(VAR socket: Socket; pathname: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Remove(socket: Socket) : BOOLEAN;

PROCEDURE Accept(socket: Socket; VAR s: Streams.Stream; bufmode: Streams.BufMode) : BOOLEAN; PROCEDURE CreateAcceptCondition(VAR condition: Conditions.Condition; socket: Socket);

PROCEDURE CreateAddress(VAR address: Networks.Address; path: ARRAY OF CHAR); PROCEDURE ConvertAddress(address: Networks.Address; VAR path: ARRAY OF CHAR); PROCEDURE SetAddress(address: Networks.Address; path: ARRAY OF CHAR);


UnixDomainSockets supports Streams and Networks for UNIX domain sockets. UNIX domain addresses are pathnames. Two independent processes on the same machine can communicate by specifying the same pathname (comparable to named pipes).

Open tries to connect to an already created socket which is associated to pathname. CreateOpenCondition and TestAndOpen my be used like their counterparts of Networks for non-blocking openings.

Listen creates a socket which may be later used to wait for incoming connections. Listen creates pathname as a special entry in the file system of type SysStat.socket. CreateSomeSocket works like Listen but selects an unique pathname (which is returned by UnixTmpNames).

Remove removes the pathname which is associated with socket. UnixDomainSockets removes all sockets on termination (see Process).

Accept waits for incoming connections for socket. The socket must have been created and prepared by Listen or CreateSomeSocket. The resulting stream s is connected with the new communication partner.

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

UnixDomainSockets supports the interface of Networks: CreateAddress takes a path name and converts it into a newly created general network address. ConvertAddress allows the reverse conversion but requires address to be returned earlier by CreateAddress. SetAddress allows to change a network address. Again, address must originate from UnixDomainSockets. General network addresses are persistent objects which allow the interface of Networks to be used which is independent from a particular network implementation.


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

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

Passing an invalid general network address (i.e. an address which does not originate from UnixDomainSockets) to ConvertAddress or SetAddress causes a type guard to fail.


UNIX domain protocol family
interface for conditions
general abstraction for network connections
input and output of persistent objects
handling of error events
stream operations
generic stream interface for sockets


Path names are limited to 108 characters due to a limit of the operating system. Longer path names are truncated silently.
Edited by: borchert, last change: 2003/07/10, revision: 1.5, converted to HTML: 2003/07/10

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