Socket:
DEFINITIONS =
BEGIN
definitions
various types used by socket channels.
ChannelHandle: TYPE = REF ChannelObject;
ChannelObject: TYPE;
TransferStatus:
TYPE = {
pending, goodCompletion, aborted, noRouteToNetwork, hardwareProblem,
invalidDestAddr,
the following apply to circuit-like media only and mostly to the first packet sent
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};
SocketStatus:
TYPE =
RECORD [
localAddr: NSAddress.NetworkAddress, state: State, incompleteGets: CARDINAL];
State: TYPE = {active, aborted};
WaitTime: TYPE = OISCPTypes.WaitTime; -- msecs
constants used by the client.
uniqueNetworkAddr: READONLY NSAddress.NetworkAddress;
defaultWaitTime: WaitTime = 60000; -- msecs
maxInternetOISPktLength: CARDINAL = 576; -- in bytes and includes header
interface
exported by SocketImpl.
procedures
AssignNetworkAddress: PROCEDURE RETURNS [NSAddress.NetworkAddress];
Create:
PROCEDURE [
local: NSAddress.NetworkAddress, send: CARDINAL ← 1,
maximum no. of send buffers used at one time
receive: CARDINAL ← 2, -- maximum no. of receive buffers used at one time
reserve: CARDINAL ← 0, -- more buffers can be allocated but not used
privateBuffers: BOOLEAN ← TRUE]
True => the buffers will be ALLOCATED for this channel; False => buffers will be shared will the system's buffers (and no new buffers will be allocated; examples of these are the EchoServer and NetworkStream Listeners). Be careful - False values can deadlock the system; users should only use one buffer at a time and return it asap without trying to grab other resources (or other buffers).
RETURNS [ChannelHandle];
Delete: PROCEDURE [cH: ChannelHandle];
Abort: PROCEDURE [cH: ChannelHandle];
Reset: PROCEDURE [cH: ChannelHandle];
GetStatus: PROCEDURE [cH: ChannelHandle] RETURNS [SocketStatus];
SetWaitTime: PROCEDURE [cH: ChannelHandle, time: WaitTime];
sending and receiving packets - they are in real buffers
PutPacket: PROCEDURE [cH: ChannelHandle, b: BufferDefs.OisBuffer];
asynchronous, return is immediate; when the buffer is finally sent the dispatcher calls b.requeueProcedure[b] to relinquish system ownership of the buffer. If the error ChannelAborted ocurs then the caller still own the buffer, b. This procedure does not attemp to broadcast a packets to ALL nets; use PutPacketToAllConnectedNets for that.
PutPacketToAllConnectedNets: PROCEDURE [cH: ChannelHandle, b: BufferDefs.OisBuffer]; -- this procedure broadcast a packet to all hosts on all locally connected nets. The user only need supply the destination socket number of the packet.
GetPacket: PROCEDURE [cH: ChannelHandle] RETURNS [b: BufferDefs.OisBuffer];
this waits - for a packet to arrive or a TimeOut or an ChannelAborted.
errors
TimeOut: ERROR; -- error when timeout ocurrs on blocked call like TransferWait
ChannelAborted: ERROR; -- error when state is aborted
ChannelError: ERROR;
error when bad software structuring, or bad parameter to calls
END.