DRCL JavaSim API

drcl.inet.socket
Class SocketContract

java.lang.Object
  |
  +--drcl.comp.Contract
        |
        +--drcl.inet.socket.SocketContract
All Implemented Interfaces:
SocketConstants

public class SocketContract
extends Contract
implements SocketConstants

This class defines the Socket contract.

Accept
The initiator sends a message that consists of:
  1. an integer of value 0 (the "accept" command),
  2. local address (long),
  3. local port (long).
In response, the reactor sends back the following message after a connection is established
  1. an integer of value 1 (the "accept-reply" message),
  2. connection ID (int),
  3. remote address (long),
  4. remote port (long),
  5. TCP data port (Port).
After connecting the data path (with the TCP data port), the initiator sends back a null signal to notify of the establishment of the data path.
Connect
The initiator sends a message that consists of:
  1. an integer of value 2 (the "connect" command),
  2. remote address (long),
  3. remote port (long),
  4. local address (long),
  5. local port (long).
In response, the reactor sends back the following message after a connection is established
  1. an integer of value 3 (the "connect-reply" message),
  2. connection ID (int),
  3. TCP data port (Port).
After connecting the data path (with the TCP data port), the initiator sends back a null signal to notify of the establishment of the data path.
Close
The initiator sends a message that consists of:
  1. an integer of value 4 (the "close" command) and
  2. connection ID (int).
In response, the reactor closes the connection and send back a null signal.
Error
In any of the above processes, if an error occurs, the reactor may send back an error message instead of a normal reply. The error message consists of:
  1. an integer of value 5 (the "error" message) and
  2. description (String).


Inner Class Summary
static class SocketContract.Message
           
 
Fields inherited from class drcl.comp.Contract
Role_INITIATOR, Role_PEER, Role_REACTOR
 
Fields inherited from interface drcl.inet.socket.SocketConstants
ACCEPT, ACCEPT_REPLY, CLOSE, CONNECT, CONNECT_REPLY, ERROR, TYPES
 
Constructor Summary
SocketContract()
           
SocketContract(int role_)
           
 
Method Summary
static SocketContract.Message accept(long localAddr_, int localPort_, Port port_)
           
static void close(int connectionID_, Port port_)
           
static SocketContract.Message connect(long remoteAddr_, int remotePort_, long localAddr_, int localPort_, Port port_)
           
static void error(java.lang.String error_, Port port_)
           
static SocketContract.Message getAcceptPack(long localAddr_, int localPort_)
           
static SocketContract.Message getAcceptReplyPack(int connectionID_, long remoteAddr_, int remotePort_, Port tcpPort_)
           
static SocketContract.Message getClosePack(int connectionID_)
           
static SocketContract.Message getConnectPack(long remoteAddr_, int remotePort_, long localAddr_, int localPort_)
           
static SocketContract.Message getConnectReplyPack(int connectionID_, Port tcpPort_)
           
 java.lang.Object getContractContent()
          Returns the content of this contract (format?).
 java.lang.String getName()
           
 
Methods inherited from class drcl.comp.Contract
getRole, match, setRole
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketContract

public SocketContract()

SocketContract

public SocketContract(int role_)
Method Detail

getName

public java.lang.String getName()
Overrides:
getName in class Contract

getContractContent

public java.lang.Object getContractContent()
Description copied from class: Contract
Returns the content of this contract (format?).
Overrides:
getContractContent in class Contract

accept

public static SocketContract.Message accept(long localAddr_,
                                            int localPort_,
                                            Port port_)

connect

public static SocketContract.Message connect(long remoteAddr_,
                                             int remotePort_,
                                             long localAddr_,
                                             int localPort_,
                                             Port port_)

close

public static void close(int connectionID_,
                         Port port_)

error

public static void error(java.lang.String error_,
                         Port port_)

getAcceptPack

public static SocketContract.Message getAcceptPack(long localAddr_,
                                                   int localPort_)

getAcceptReplyPack

public static SocketContract.Message getAcceptReplyPack(int connectionID_,
                                                        long remoteAddr_,
                                                        int remotePort_,
                                                        Port tcpPort_)

getConnectPack

public static SocketContract.Message getConnectPack(long remoteAddr_,
                                                    int remotePort_,
                                                    long localAddr_,
                                                    int localPort_)

getConnectReplyPack

public static SocketContract.Message getConnectReplyPack(int connectionID_,
                                                         Port tcpPort_)

getClosePack

public static SocketContract.Message getClosePack(int connectionID_)

DRCL JavaSim API

Copyright © 2001 - DRCL, OSU     ~ Back to JavaSim Home ~