org.exolab.core.ipc
Class TcpServerService

java.lang.Object
  extended byorg.exolab.core.ipc.TcpServerService
All Implemented Interfaces:
IpcServerIfc

public class TcpServerService
extends java.lang.Object
implements IpcServerIfc

Create a listener socket and wait for requests to come in. When a connection is made add the new object to the list of active connections and spawn a new thread to listen to the connection.

Version:
$Revision: 1.7 $ $Date: 2003/07/12 00:23:57 $
Author:
Jim Mourikis
See Also:
org.exolab.core.ipc.IpcServerService, TcpService, Server

Constructor Summary
TcpServerService(java.net.InetAddress address, int port, NotifierIfc notifier)
          Sets up a listener port and adds a notifier to call with all received messages.
TcpServerService(int port, NotifierIfc notifier)
          Sets up a listener port and adds a notifier to call with all received messages.
TcpServerService(NotifierIfc notifier)
          Sets up a listener port on the next free port as allocated by the system and adds a notifier to call with all received messages.
 
Method Summary
 java.lang.String getHost()
          Return the machines address.
 int getPort()
          Return the port number this server is listening on.
 void shutdownAll()
          Shutdown all active connections, including the server connection.
 void start()
          Start the service running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpServerService

public TcpServerService(NotifierIfc notifier)
                 throws java.io.IOException
Sets up a listener port on the next free port as allocated by the system and adds a notifier to call with all received messages.

Parameters:
notifier - the client handle to call when data is received.

TcpServerService

public TcpServerService(int port,
                        NotifierIfc notifier)
                 throws java.io.IOException
Sets up a listener port and adds a notifier to call with all received messages.

Parameters:
port - the port to accept connections on.
notifier - the client handle to call when data is received.

TcpServerService

public TcpServerService(java.net.InetAddress address,
                        int port,
                        NotifierIfc notifier)
                 throws java.io.IOException
Sets up a listener port and adds a notifier to call with all received messages.

Parameters:
address - the local IP address to bind to. May be null.
port - the port to accept connections on.
notifier - the client handle to call when data is received.
Method Detail

start

public void start()
Start the service running. This call never returns until the service is shutdown. When a connection is made, the new socket is added to the connections list, and a new thread is spawned to receive messages from the socket.

Specified by:
start in interface IpcServerIfc
Throws:
java.io.IOException - If a failure on connection occurs.

shutdownAll

public void shutdownAll()
                 throws java.io.IOException
Shutdown all active connections, including the server connection.

Specified by:
shutdownAll in interface IpcServerIfc
Throws:
java.io.IOException - If the service reports an error during shutdown.

getPort

public int getPort()
Return the port number this server is listening on.

Specified by:
getPort in interface IpcServerIfc
Returns:
int The port number the server is using.

getHost

public java.lang.String getHost()
Return the machines address.

Specified by:
getHost in interface IpcServerIfc
Returns:
String The machines Ip address.


Copyright © 1999-2005 The Exolab Group. All Rights Reserved.