next up previous
Next: serverswitch Up: simsocket Previous: clientsocket

ServerSocket


     NAME
	  serversocket - instantiated by Servers to act	as its socket
	  talking to Clients

     DESCRIPTION
	  This subclass	of SocketIO is instantiated by the Server
	  program, one for each	connected Client. When connected there
	  are thus a one-to-one	correspondence between a ServerSocket
	  object and a ClientSocket object.

     EXAMPLES
	  See the users	manual in simioprocess.ps

     AUTHOR
	  Boris	Magnusson, Lund	Institute of Technology.

     DETAILED INTERFACE
	     SocketIO class ServerSocket;
	  Object used by Server	to  acually  talk  to  a  Client.  The
	  parameter,  Channel,	is  normally  the result returned by a
	  call to SocketService.NextRequest.

	  ServerSocket object is also similar to a Simula file object.
	  The  address of the ClientSocket object it will be connected
	  to is, however, not known beforehand since the  Client  will
	  take the initiative to call the Server. The `Open' operation
	  is usually not called	directly by  the  application  program
	  but is called	by the NextRequest operation in	SocketService.
	  As a result the address of the ServerSocket is  defined  (as
	  an  InternetAddress  object  denoting	 the  connected	Client
	  machine).  Also notice that if  Sockets  are	not  propperly
	  closed,  say if the program is terminated due	to some	error,
	  it takes a while (some minutes) for  Unix  to	 realize  that
	  processes  using the Socket are gone.	 In the	meantime it is
	  not possible to start	a  new	Server	using  the  same  Port
	  number. Operations for I/O are those described in SocketIO.

	   Super: SocketConnection, SocketBasics.
	   Kind: Concrete.
	   Init: SocketSwitch.NextRequest calls	Open.
	   Sequencing: ;
	   : (IsOpen / Open  (GetChannelNo/GetClientAddress/<IO-ops>)*
	  Close)*
	   : <IO-ops>=(OutRecord / InRecord / EndFile)*	 /
	   :	      (Read / Write / EndFile)*

     OPERATIONS
     Open
	     procedure Open(ChannelNumber,InternetAdr);
	     integer ChannelNumber; ! Unix Channel, from by 'Accept'
	     via NextRequest;
	     ref(InterNetAddress) InternetAdr; ! Address of Client
	     that connected to us;
	  Initiate this	object as open as a result  of	an  succesfull
	  call	to  Accept.  This  is  managed by NextRequest in class
	  SocketSwitch,	so there is no need  to	 call  this  operation
	  directly.

     GetClientAddress
	     ref(InterNetAddress) procedure GetClientAddress;
	  Return the Internet address of the  Client  this  Socket  is
	  connected to.