SSF.OS.TCP.test
Class tcpServer

java.lang.Object
  |
  +--SSF.OS.ProtocolSession
        |
        +--SSF.OS.TCP.test.tcpServer
All Implemented Interfaces:
com.renesys.raceway.DML.Configurable

public class tcpServer
extends ProtocolSession

A simple TCP server application provided as an example. The server configures itself from the DML file. The client-server protocol is absolutely minimal: the client sends to server's well known address just one integer that specifies the total amount of virtual data it requests. After receiving a client's request, the server spawns a slave server that sends the virtual data to the client until the request is fulfilled. The default is no limit on the number of clients, unless the attribute client_limit is set. There is no limit on the number of servers that can coexist in a single Host as long as each tcpServer has a distinct wellKnownPort number.


Field Summary
 int client_limit
          max number of simultaneous client connections serviced byf this server - default is unlimited (Integer.MAX_VALUE).
 int clientNumber
          ID of the latest client connection serviced by this server
 boolean debug
          default is don't print verbose debugging information
 Host localHost
          Host entity where this pseudo-protocol is installed
 int localIP
          Host's IP address
 java.lang.String localNHI
          Host's NHI address
 tcpSocket lsd
          "listening" socket of this server
 int qlimit
          The maximum size of pending connection request queue, Qlimit, that determines when the server socket rejects connection requests.
 int request_size
          size of data request object from matching client
 boolean show_report
          default is show summary session information
 socketMaster socketms
          Host's Socket ProtocolSession
 
Fields inherited from class SSF.OS.ProtocolSession
name, use
 
Constructor Summary
tcpServer()
          Constructors
 
Method Summary
 void config(com.renesys.raceway.DML.Configuration cfg)
          Server configuration.
 void init()
          Initialization routine, called by the ProtocolGraph after instantiation.
 boolean push(ProtocolMessage message, ProtocolSession fromSession)
          Routine to call when a message is being sent to ("pushed into") this ProtocolSession by another ProtocolSession.
 void serv()
           
 
Methods inherited from class SSF.OS.ProtocolSession
close, closed, debugIdentifier, inGraph, open, opened, pushAfterDelay, pushAfterDelayFailed, setGraph, version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request_size

public int request_size
size of data request object from matching client


lsd

public tcpSocket lsd
"listening" socket of this server


client_limit

public int client_limit
max number of simultaneous client connections serviced byf this server - default is unlimited (Integer.MAX_VALUE).


clientNumber

public int clientNumber
ID of the latest client connection serviced by this server


qlimit

public int qlimit
The maximum size of pending connection request queue, Qlimit, that determines when the server socket rejects connection requests.

See Also:
tcpSocket

localHost

public Host localHost
Host entity where this pseudo-protocol is installed


localIP

public int localIP
Host's IP address


localNHI

public java.lang.String localNHI
Host's NHI address


socketms

public socketMaster socketms
Host's Socket ProtocolSession


debug

public boolean debug
default is don't print verbose debugging information


show_report

public boolean show_report
default is show summary session information

Constructor Detail

tcpServer

public tcpServer()
Constructors

Method Detail

config

public void config(com.renesys.raceway.DML.Configuration cfg)
            throws com.renesys.raceway.DML.configException
Server configuration. Supported DML attributes:
   ProtocolSession [ name server use SSF.OS.TCP.test.tcpServer
     port          %I     # server's well known port (int)
     client_limit  %I     # max number of simultaneous established client
                          # connections, if omitted, default is unlimited.
                          # If exceeded, connection request is ignored
                          # and left to time out.

     queue_limit   %I     # maximum size of pending connection request
                          # queue, Qlimit, if omitted default is 5.
                          # Determines the total number of pending
                          # connection requests (see SSF.OS.TCP.tcpSocket).
                          # If exceeded, the listening socket sends RESET
                          # to client and drops the request.

     request_size  %I     # nominal size of client request datagram (bytes, int)
                          # (must be the same for the client)

     show_report   %S     # print client-server session summary report, true/false
     debug         %S     # print verbose server diagnostics, true/false
   ]
 

Specified by:
config in interface com.renesys.raceway.DML.Configurable
Overrides:
config in class ProtocolSession
com.renesys.raceway.DML.configException

init

public void init()
Description copied from class: ProtocolSession
Initialization routine, called by the ProtocolGraph after instantiation. The order of initialization of a set of protocols is unspecified, so other methods (like open()) may be called before init(). Resources (like connection tables) that may be needed by open() should therefore be created in the ProtocolSession constructor.

Overrides:
init in class ProtocolSession

serv

public void serv()

push

public boolean push(ProtocolMessage message,
                    ProtocolSession fromSession)
             throws ProtocolException
Description copied from class: ProtocolSession
Routine to call when a message is being sent to ("pushed into") this ProtocolSession by another ProtocolSession. The pusher sends a reference to itself in the second argument. This push happens immediately, without any simulation time elapsing, regardless of other activities taking place in the ProtocolGraph.

If you desire "safe" interaction with other CPU activities, even though your push() consumes no measurable/modelable CPU cycles, define the "cpudelay true" attribute for the ProtocolGraph and use pushAfterDelay(message,fromSession,0.0). This will guarantee proper ordering; that is, the framework will wait until the CPU is free before proceeding with the requested push().

Specified by:
push in class ProtocolSession
ProtocolException