-- NetworkStream.mesa (last edited by: Garlick on: January 26, 1981  9:55 AM)

  Stream USING [Handle, SubSequenceType],
  System USING [NetworkAddress];

NetworkStream: DEFINITIONS =

  -- definitions

  -- various types and constants used by Network Stream clients.
  WaitTime: TYPE = LONG CARDINAL; -- msecs
  defaultWaitTime: WaitTime = 60000; -- msecs
  infiniteWaitTime: READONLY WaitTime;
  ClassOfService: TYPE = {bulk, transactional};
  SuspendReason: TYPE = {
    notSuspended, transmissionTimeout, noRouteToDestination, remoteReject,
  FailureReason: TYPE = {
    timeout, noRouteToDestination, noServiceAtDestination, -- all media
    -- the following apply only to circuit-oriented networks (e.g. phone network)
    noAnswerOrBusy, -- auto-dial case only
    noTranslationForDestination, -- no phone number for this destination
    circuitInUse, -- being used to talk to another destination
    circuitNotReady, -- dial the phone or connect modems (non-auto-dial case)
    noDialingHardware, dialerHardwareProblem};
  ListenerHandle: TYPE [2];
  uniqueNetworkAddr: READONLY System.NetworkAddress;
  ConnectionID: TYPE = RECORD [WORD];
  uniqueConnID: ConnectionID = [0];
  unknownConnID: ConnectionID = [0];

  -- interface

  -- exported by NetworkStreamMgr
  -- procedures
  -- This procedure creates a network stream to the specified remote address.
  Create: PROCEDURE [
    remote: System.NetworkAddress, timeout: WaitTime ← defaultWaitTime,
    classOfService: ClassOfService ← bulk] RETURNS [Stream.Handle];
  -- This procedure creates the sequenced packet transducer with all its parameters
  CreateTransducer: PROCEDURE [
    local, remote: System.NetworkAddress, localConnID, remoteConnID: ConnectionID,
    activelyEstablish: BOOLEAN, timeout: WaitTime ← defaultWaitTime,
    classOfService: ClassOfService ← bulk] RETURNS [Stream.Handle];
  AssignNetworkAddress: PROCEDURE RETURNS [System.NetworkAddress];
  FindAddresses: PROCEDURE [sH: Stream.Handle]
    RETURNS [local, remote: System.NetworkAddress];
  SetWaitTime: PROCEDURE [sH: Stream.Handle, time: WaitTime];
  CreateListener: PROCEDURE [addr: System.NetworkAddress]
    RETURNS [ListenerHandle];
  DeleteListener: PROCEDURE [listenerH: ListenerHandle];
  Listen: PROCEDURE [
    listenerH: ListenerHandle, listenTimeout: WaitTime ← infiniteWaitTime,
    streamTimeout: WaitTime ← infiniteWaitTime,
    classOfService: ClassOfService ← bulk] RETURNS [Stream.Handle];
  -- errors and signals
  ConnectionSuspended: ERROR [why: SuspendReason];
  ConnectionFailed: SIGNAL [why: FailureReason];
  IllegalAddress: ERROR; -- illegal network address for CreateListener
  ListenTimeout: SIGNAL; -- resumeable

  -- optional close protocol using subsequence types
  -- definitions
  CloseStatus: TYPE = {good, noReply, incomplete};
  closeSST: Stream.SubSequenceType = 254;
  closeReplySST: Stream.SubSequenceType = 255;
  -- interface
  -- exported by NetworkStreamMgr
  -- procedures
  Close: PROCEDURE [sH: Stream.Handle] RETURNS [CloseStatus];
  CloseReply: PROCEDURE [sH: Stream.Handle] RETURNS [CloseStatus];



(trimmed to Teak)
Time: January 22, 1980  10:37 PM  By: Dalal  Action: made ListenerHandle a LONG.
Time: January 22, 1980  10:37 PM  By: BLyon  Action: Changed SpecialSystem to System, ListenerHandle is opaque TYPE, made uniqueNetworkAddress READONLY (from CONSTANT).
Time: August 6, 1980  10:21 AM  By: Garlick  Action: Added several FailureReason's for circuit-oriented networks.
Time: October 10, 1980  4:47 PM  By: Garlick  Action: Added FailureReason noAnswerOrBusy.
Time: January 26, 1981  9:55 AM  By: Garlick  Action: Added FailureReason noServiceAtDestination and SuspendReason remoteServiceDisappeared.  Deleted ERROR AttentionTimeout and added SIGNAL ListenTimeout.  Made several timeout values default.  Added a ClassOfService parameter to Create, CreateTransducer, and Listen. Added infiniteWaitTime.