PupStream.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
HGM January 15, 1981 6:36 PM
Andrew Birrell May 12, 1983 10:55 am
DIRECTORY
IO USING [STREAM],
PupTypes USING [Pair, PupAddress, PupHostID, PupNetID, PupSocketID],
Rope USING [ROPE];
PupStream: CEDAR DEFINITIONS =
BEGIN
Copied things from PupTypes
PupAddress: TYPE = PupTypes.PupAddress;
PupNetID: TYPE = PupTypes.PupNetID;
PupHostID: TYPE = PupTypes.PupHostID;
PupSocketID: TYPE = PupTypes.PupSocketID;
TYPEs
Tocks: TYPE = RECORD [CARDINAL];
veryLongWait: Tocks = [LAST[CARDINAL]];
veryShortWait: Tocks = [0];
PupOpenMode: TYPE = {alreadyOpened, sendRfc, wait};
CloseReason:
TYPE = {
localClose, localAbort, remoteClose, noRouteToNetwork, transmissionTimeout, remoteReject};
Byte Stream Interface
PupByteStreamCreate: PROCEDURE [remote: PupAddress, ticks: Tocks] RETURNS [IO.STREAM];
PupByteStreamAbort: PROCEDURE [IO.STREAM, Rope.ROPE]; -- instead of clean close
SendMark: PROCEDURE[IO.STREAM, [0..256)]; -- send mark byte
ConsumeMark: PROCEDURE[IO.STREAM] RETURNS [ [0..256) ]; -- legal iff EndOf[]
SendAttention: PROCEDURE[IO.STREAM]; -- sends asynchronous "interrupt" on stream
WaitAttention: PROCEDURE[IO.STREAM]; -- waits until other end sends an "interrupt".
ERRORs
TimeOut:
SIGNAL[nextIndex:
INT];
Raised during input operation if no data arrives within the interval specified when the stream was created (even although the other end is responding to our probes).
StreamClosing:
ERROR [why: CloseReason, text: Rope.
ROPE];
Raised during i/o operation if stream has been aborted or closed by either end, or if the other end is not responding to our probes. Also raised when creating a stream if creation fails.
Listeners
PupListener: TYPE = REF PupListenerObject;
PupListenerObject: TYPE;
CreatePupByteStreamListener:
PROCEDURE [
local: PupSocketID, proc: PROCEDURE [IO.STREAM, PupAddress],
ticks: Tocks, filter: PROCEDURE [PupAddress] ← DontReject]
RETURNS [PupListener];
DestroyPupListener: PROCEDURE [PupListener];
DontReject: PROCEDURE [PupAddress];
RejectThisRequest: SAFE ERROR [error: Rope.ROPE];
Used only by Listeners+Debugging
PupByteStreamMake:
PROCEDURE [
local: PupSocketID, remote: PupAddress, ticks: Tocks,
mode: PupOpenMode, id: PupTypes.Pair] RETURNS [IO.STREAM];
Performance tuning and debugging
Call these before creating the connection
SetMaxAllocation: PROCEDURE [CARDINAL];
SetMaxBufferSize: PROCEDURE [CARDINAL];
SetPinging: PROCEDURE [BOOLEAN];
Tocks
SecondsToTocks: PROCEDURE [CARDINAL] RETURNS [Tocks];
MsToTocks: PROCEDURE [CARDINAL] RETURNS [Tocks];
On/Off
PupPackageMake: PROCEDURE;
PupPackageDestroy: PROCEDURE;
NameConversion
GetPupAddress: SAFE PROC [PupSocketID, Rope.ROPE] RETURNS[ PupAddress ];--Parse or NameLookup
PupNameLookup: SAFE PROC [PupSocketID, Rope.ROPE] RETURNS[ PupAddress ];--NameLookup only
NameLookupErrorCode: TYPE = {noRoute, noResponse, errorFromServer}; -- if error
ERRORs
PupNameTrouble: ERROR [e: Rope.ROPE, code: NameLookupErrorCode];
TockConversionTroubles: ERROR;