DRCL J-Sim API

drcl.inet.socket
Class SocketMaster

java.lang.Object
  extended bydrcl.inet.socket.SocketMaster

public class SocketMaster
extends java.lang.Object

Application helper class for using InetSocket. The master component must call processSocket(Object, Port) in process(Object, Port) to relay socket contract related messages for processing in this helper class.

SocketMaster can work with both TCP_socket (for single-session applications) and TCP_full (for multi-session applications). By default, SocketMaster is configured to work with multiple TCP sessions and TCP_full. To work with single-session applications (and communicate with TCP_socket), the application should disable the multi-session flag with setMultiSessionEnabled(boolean).

See Also:
SocketContract

Constructor Summary
SocketMaster(Port controlPort_, Component masterComp_)
           
 
Method Summary
 void aAccept(InetSocket serverSocket_, NonblockingSocketHandler h_)
          Accepting a new connection at the server socket.
 InetSocket accept(InetSocket serverSocket_)
          Accepting a new connection at the server socket.
 void aClose(InetSocket socket_, NonblockingSocketHandler h_)
          Closes the server/client socket.
 void aConnect(InetSocket clientSocket_, long remoteAddress_, int remotePort_, NonblockingSocketHandler h_)
          Connecting to a remote node at the client socket.
 void bind(InetSocket socket_, long localAddress_, int localPort_)
          Binds the server/client socket to a specific (address, port).
 void close(InetSocket socket_)
          Closes the server/client socket.
 void connect(InetSocket clientSocket_, long remoteAddress_, int remotePort_)
          Connecting to a remote node at the client socket.
 java.lang.String info()
           
 boolean isMultiSessionEnabled()
           
 void listen(InetSocket serverSocket_, int backlog_)
           
 InetSocket newSocket()
          Creates and installs a new server/client InetSocket in this application.
 boolean processSocket(java.lang.Object data_, Port inPort_)
          Processes the socket contract related messages for the master component.
 void reset()
           
 void setMultiSessionEnabled(boolean enabled_)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketMaster

public SocketMaster(Port controlPort_,
                    Component masterComp_)
Method Detail

reset

public void reset()

info

public java.lang.String info()

newSocket

public InetSocket newSocket()
Creates and installs a new server/client InetSocket in this application.


listen

public void listen(InetSocket serverSocket_,
                   int backlog_)

accept

public InetSocket accept(InetSocket serverSocket_)
                  throws java.io.IOException
Accepting a new connection at the server socket. It returns the client socket that handles the new connection.

Throws:
java.io.IOException

aAccept

public void aAccept(InetSocket serverSocket_,
                    NonblockingSocketHandler h_)
             throws java.io.IOException
Accepting a new connection at the server socket. This call is nonblocking. The handler (h_) is called back when a new connection is established from the server socket.

Throws:
java.io.IOException

connect

public void connect(InetSocket clientSocket_,
                    long remoteAddress_,
                    int remotePort_)
             throws java.io.IOException
Connecting to a remote node at the client socket.

Throws:
java.io.IOException

aConnect

public void aConnect(InetSocket clientSocket_,
                     long remoteAddress_,
                     int remotePort_,
                     NonblockingSocketHandler h_)
              throws java.io.IOException
Connecting to a remote node at the client socket. This call is nonblocking. The handler (h_) is called back when the connection is established.

Throws:
java.io.IOException

close

public void close(InetSocket socket_)
           throws java.io.IOException
Closes the server/client socket.

Throws:
java.io.IOException

aClose

public void aClose(InetSocket socket_,
                   NonblockingSocketHandler h_)
            throws java.io.IOException
Closes the server/client socket. This call is nonblocking. The handler (h_) is called back when the connection is closed.

Throws:
java.io.IOException

bind

public void bind(InetSocket socket_,
                 long localAddress_,
                 int localPort_)
Binds the server/client socket to a specific (address, port).


isMultiSessionEnabled

public boolean isMultiSessionEnabled()

setMultiSessionEnabled

public void setMultiSessionEnabled(boolean enabled_)

processSocket

public boolean processSocket(java.lang.Object data_,
                             Port inPort_)
Processes the socket contract related messages for the master component. Returns true if the socket master consumes the data.


DRCL J-Sim API

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