    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class JavaAgent.agent.SocketInterface

    java.lang.Object
       |
       +----JavaAgent.agent.CommInterface
               |
               +----JavaAgent.agent.SocketInterface

public class SocketInterface
extends CommInterface

Subclass of CommInterface which uses sockets for message passing. When instantiated, a ServerThread is started which creates a ServerSocket and waits in an infinite while loop waiting for client accepts. Each client accept spawns a MessageThread which reads and interprets the message. Each message transmission starts a ClientThread which retrieves the correct SocketAddress and binds to the remote ServerSocket.

Copyright (c) 1995, H. Robert Frost, Stanford University. All rights reserved.

Copyright (c) 1996, H. Robert Frost, Enterprise Integration Technologies, Inc. All rights reserved.

RESTRICTED RIGHTS LEGEND: Use, duplication or disclosure by the Government is subject to restrictions as set forth in subparagraph(c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 and in similar clauses in the FAR and NASA FAR supplement.

This software is bound by the terms and conditions listed in the attached LICENSE file.

##

port
  The port which this SocketInterface is connected to on the local machine.
server
  Server socket.
server_thread
  Server thread.

##

SocketInterface(Agent, int)
  Contructs a SocketInterface for the specified Agent on the specified local port.

##

CreateServer(int)
  Creates a Server Socket on the specified port.
disconnect()
  Called by the Agent to disconnect the SocketInterface.
sendMessage(KQMLmessage)
  Called to send a given KQMLmessage.

##

port

     public int port

  The port which this SocketInterface is connected to on the local machine.

server

     protected ServerSocket server

  Server socket.

server_thread

     protected ServerThread server_thread

  Server thread.

##

SocketInterface

     public SocketInterface(Agent A,
                            int port)

  Contructs a SocketInterface for the specified Agent on the specified local port.

  Parameters:
    A - Agent which this CommInterface represents.
    port - Local port to which the Server Socket should be connected. If zero, connect to an anonymous port.

##

disconnect

     protected void disconnect()

  Called by the Agent to disconnect the SocketInterface. First stops the ServerThread, then closes the ServerSocket.

  Overrides:
    disconnect in class CommInterface

sendMessage

     protected void sendMessage(KQMLmessage message)

  Called to send a given KQMLmessage. A TimerThread is started which will stop the ClientThread after a specified timeout interval.

  Parameters:
    message - The KQMLmessage to send.
  Overrides:
    sendMessage in class CommInterface

CreateServer

     protected int CreateServer(int port)

  Creates a Server Socket on the specified port.

  Parameters:
    port - The local port to which the Server Socket should be bound.
    The - actual port to which the Server Socket was bound, or -1 if there was an error.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index