Oberon || Library || Module Index || Search Engine || Definition || Module
CONST connectFailed = 0; CONST sendFailed = 1; CONST gotNoResponse = 2; CONST invalidResponse = 3; CONST invalidPort = 4; CONST noUser = 5; CONST unknownError = 6; CONST hiddenUser = 7; CONST otherError = 8; CONST timeoutConnect = 9; CONST timeoutResponse = 10; CONST errors = 11; TYPE ErrorCode = SHORTINT; TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: ErrorCode; foreignAddress: IPv4Addresses.SocketAddress; localAddress: IPv4Addresses.SocketAddress; response: ARRAY 512 OF CHAR; END; VAR error: Events.EventType; VAR errormsg: ARRAY errors OF Events.Message;
PROCEDURE GetIdent(foreignAddress: IPv4Addresses.SocketAddress; localAddress: IPv4Addresses.SocketAddress; timelimit: Times.Time; VAR opsys, charset: ARRAY OF CHAR; VAR ident: ARRAY OF CHAR; VAR errors: RelatedEvents.Object) : BOOLEAN;
GetIdent sends a query to the host specified in foreignAddress using the port numbers out of foreignAddress and localAddress. The timelimit parameter specifies how long GetIdent will wait until it gives up. NIL may be passed to timelimit. In this case, a default value of 5 seconds is taken.
A successful response from an RFC 1413 server includes three fields: the specification of an operating system (e.g. ``UNIX''), a character set (e.g. ``US-ASCII''), and an identification string which is represented in the character set specified by charset.
In case of failures, FALSE is returned, and error events are made available through errors.
VAR errors: RelatedEvents.Object; port: INTEGER; socket: IPv4TCPSockets.Socket; s: Streams.Stream; local, peer: IPv4Addresses.SocketAddress; opsys, charset, ident: ARRAY 65 OF CHAR;The listening socket is set up as usual. Note that we retrieve the local address by IPv4TCPSockets.GetName:
NEW(errors); RelatedEvents.QueueEvents(errors); IF ~IPv4TCPSockets.Listen(socket, port, errors) OR ~IPv4TCPSockets.GetName(socket, local, errors) THEN Conclusions.Conclude(errors, Errors.fatal, ""); END;In case of an incoming connection we can attempt to retrieve the RFC 1413 information:
IF IPv4TCPSockets.Accept(socket, s, Streams.onebuf, peer) THEN IF RFC1413Requests.GetIdent(peer, local, NIL, opsys, charset, ident, errors) THEN (* got RFC 1413 identification *) ELSE (* unable to retrieve RFC 1413 identification *) END; (* ... *) END;
Oberon || Library || Module Index || Search Engine || Definition || Module