Next: socketbasics
Up: simsocket
Previous: serversocket
ServerSwitch
NAME
serverswitch - part of Server to define a Port and a
Protocol and receive requests
DESCRIPTION
A ServerSwitch object receives requests from Clients who
wants to connect to the Server. If a Server defines several
Ports (maybe providing different protocols or functionality)
then there will several objects of class ServerSwitch.
EXAMPLES
See the users manual in simioprocess.ps
AUTHOR
Boris Magnusson, Lund Institute of Technology.
DETAILED INTERFACE
SocketBasics class ServerSwitch(ServerAddress);
ref(InterNetAddress) ServerAddress; !- Defines port and
protocol.;
There is usually only one object of this class in a Server
where it defines a Port with a Protocol. External requests
to connect are handled by the operation NextRequest. It
initializes an object of class ServerSocket to be used to
service the connection.
The functionality provided by the library SimIOProcess can
be used to avoid calling NextRequest until a request is
actually present (and thus avoiding the possible hang). See
this library for details.
Class used by a server to define a Server-Port. Receives
requests from Clients (see class ClientConnection) who
whants to talk to us. Our result of the request is another
channel which is then used for the actual talking (see
ServerConnection).
Super: SocketBasics.;
Kind: Concrete. ;
Init: the parameter must be a valid, unique, Port number. ;
Sequencing: (IsOpen/Open (GetChannelNo/<IO-ops>)* Close)*;
<IO-ops>=NextRequest ;
OPERATIONS
Open
boolean procedure Open(Qlength);
integer Qlength; ! Maximum number of unanswered Clients
waiting ;
Open the socket-port for incomming requests. Qlength is the
maximum number of unanswered Clients we allow. If more
Clients have called tried to contact us (ClientSocket.Open)
but are not yet answered we are considered overrun and
further calls are refused.
NextRequest
ref(ServerSocket) procedure NextRequest(ReceiverSocket);
ref(ServerSocket) ReceiverSocket; ! Will be connected to
Client;
Wait until there is a Client trying to contact us (calling
ClientSocket.Open). Then return with ReceiverSocket
initiated to use the channel to the Client. ReceiverSocket
also carries the InternetNumber of the contacting Client.
When this rendezvous has taken place, both Server and Client
continue their execution. Returns None if the there was some
error situation detected.