DRCL J-Sim API

drcl.inet.socket
Class SocketContract

java.lang.Object
  extended bydrcl.comp.Contract
      extended bydrcl.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).
  4. message ID(Object).
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).
  6. message ID(Object).
The message ID in the reply is the same object as in the reqest. After connecting the data path (with the TCP data port), the initiator sends back an established message through the TCP data port 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).
  6. message ID(Object).
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).
  4. message ID(Object).
The message ID in the reply is the same object as in the reqest. After connecting the data path (with the TCP data port), the initiator sends back an established message to the TCP data port 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).
  3. message ID(Object).
In response, the reactor sends back the following message after the connection is closed:
  1. an integer of value 5 (the "close-reply" command) and
  2. connection ID (int).
  3. message ID(Object).
The message ID in the reply is the same object as in the reqest.
Established
The initiator uses this message to notify of the establishment of the data path (see "Accept" and "Connect"). This message is needed because the data path is established on demand. The initiator sends a message that consists of:
  1. an integer of value 6 (the "established" message) and
  2. connection ID (int).
In response, the reactor sends back a null to complete the signaling.
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 6 (the "error" message) and
  2. description (String).


Nested Class Summary
static class SocketContract.Message
           
 
Field Summary
 
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, CLOSE_REPLY, CONNECT, CONNECT_REPLY, ERROR, ESTABLISHED, LISTEN, TYPES
 
Constructor Summary
SocketContract()
           
SocketContract(int role_)
           
 
Method Summary
static void accept(long localAddr_, int localPort_, java.lang.Object msgID_, Port port_)
          Send out "accept" command using "send".
static SocketContract.Message accept(long localAddr_, int localPort_, Port port_)
          Send out "accept" command using "send-receive".
static void acceptReply(int connectionID_, long remoteAddr_, int remotePort_, Port tcpPort_, java.lang.Object msgID_, Port port_)
           
static void close(int connectionID_, java.lang.Object msgID_, Port port_)
          Send out "close" command using "send".
static SocketContract.Message close(int connectionID_, Port port_)
          Send out "close" command using "send-receive".
static void close(long localAddr_, int localPort_, java.lang.Object msgID_, Port port_)
          Send out "close" command using "send".
static SocketContract.Message close(long localAddr_, int localPort_, Port port_)
          Send out "close" command using "send-receive".
static void closeReply(int connectionID_, java.lang.Object msgID_, Port port_)
           
static void connect(long remoteAddr_, int remotePort_, long localAddr_, int localPort_, java.lang.Object msgID_, Port port_)
          Send out "connect" command using "send".
static SocketContract.Message connect(long remoteAddr_, int remotePort_, long localAddr_, int localPort_, Port port_)
          Send out "connect" command using "send-receive".
static void connectReply(int connectionID_, Port tcpPort_, java.lang.Object msgID_, Port port_)
           
static void error(java.lang.String error_, int connectionID_, long remoteAddr_, int remotePort_, long localAddr_, int localPort_, java.lang.Object msgID_, Port port_)
           
static void established(int connectionID_, Port port_)
          Send out the "established" message.
static SocketContract.Message getAcceptPack(long localAddr_, int localPort_, java.lang.Object msgID_)
           
static SocketContract.Message getAcceptReplyPack(int connectionID_, long remoteAddr_, int remotePort_, Port tcpPort_, java.lang.Object msgID_)
           
static SocketContract.Message getClosePack(int connectionID_)
           
static SocketContract.Message getCloseReplyPack(int connectionID_, java.lang.Object msgID_)
           
static SocketContract.Message getConnectPack(long remoteAddr_, int remotePort_, long localAddr_, int localPort_, java.lang.Object msgID_)
           
static SocketContract.Message getConnectReplyPack(int connectionID_, Port tcpPort_, java.lang.Object msgID_)
           
 java.lang.Object getContractContent()
          Returns the content of this contract (format?).
 java.lang.String getName()
           
static void listen(long localAddr_, int localPort_, int bufferSize_, Port port_)
          Send out "listen" command.
 
Methods inherited from class drcl.comp.Contract
getRole, match, setRole
 
Methods inherited from class java.lang.Object
equals, 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()
Specified by:
getName in class Contract

getContractContent

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

Specified by:
getContractContent in class Contract

listen

public static void listen(long localAddr_,
                          int localPort_,
                          int bufferSize_,
                          Port port_)
Send out "listen" command.


accept

public static SocketContract.Message accept(long localAddr_,
                                            int localPort_,
                                            Port port_)
Send out "accept" command using "send-receive".


accept

public static void accept(long localAddr_,
                          int localPort_,
                          java.lang.Object msgID_,
                          Port port_)
Send out "accept" command using "send".


connect

public static SocketContract.Message connect(long remoteAddr_,
                                             int remotePort_,
                                             long localAddr_,
                                             int localPort_,
                                             Port port_)
Send out "connect" command using "send-receive".


connect

public static void connect(long remoteAddr_,
                           int remotePort_,
                           long localAddr_,
                           int localPort_,
                           java.lang.Object msgID_,
                           Port port_)
Send out "connect" command using "send".


close

public static SocketContract.Message close(int connectionID_,
                                           Port port_)
Send out "close" command using "send-receive".


close

public static SocketContract.Message close(long localAddr_,
                                           int localPort_,
                                           Port port_)
Send out "close" command using "send-receive".


close

public static void close(int connectionID_,
                         java.lang.Object msgID_,
                         Port port_)
Send out "close" command using "send".


close

public static void close(long localAddr_,
                         int localPort_,
                         java.lang.Object msgID_,
                         Port port_)
Send out "close" command using "send".


error

public static void error(java.lang.String error_,
                         int connectionID_,
                         long remoteAddr_,
                         int remotePort_,
                         long localAddr_,
                         int localPort_,
                         java.lang.Object msgID_,
                         Port port_)

connectReply

public static void connectReply(int connectionID_,
                                Port tcpPort_,
                                java.lang.Object msgID_,
                                Port port_)

acceptReply

public static void acceptReply(int connectionID_,
                               long remoteAddr_,
                               int remotePort_,
                               Port tcpPort_,
                               java.lang.Object msgID_,
                               Port port_)

closeReply

public static void closeReply(int connectionID_,
                              java.lang.Object msgID_,
                              Port port_)

established

public static void established(int connectionID_,
                               Port port_)
Send out the "established" message.


getAcceptPack

public static SocketContract.Message getAcceptPack(long localAddr_,
                                                   int localPort_,
                                                   java.lang.Object msgID_)

getAcceptReplyPack

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

getConnectPack

public static SocketContract.Message getConnectPack(long remoteAddr_,
                                                    int remotePort_,
                                                    long localAddr_,
                                                    int localPort_,
                                                    java.lang.Object msgID_)

getConnectReplyPack

public static SocketContract.Message getConnectReplyPack(int connectionID_,
                                                         Port tcpPort_,
                                                         java.lang.Object msgID_)

getClosePack

public static SocketContract.Message getClosePack(int connectionID_)

getCloseReplyPack

public static SocketContract.Message getCloseReplyPack(int connectionID_,
                                                       java.lang.Object msgID_)

DRCL J-Sim API

Copyright © 1998-2003 Distributed Real-time Computing Lab (DRCL). All Rights Reserved.     ~ To J-Sim Home ~