|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.core.ipc.TcpService
Implement a standard Tcp service, with one send and one receive buffer. add a 10 second timeout on the send buffer in case of failures. Receive buffers are blocking, but can have any parameters set as required by getting the underlying soket and setting parameters as required.
IpcIfc
,
Client
,
TcpServerService
Field Summary | |
static int |
DEFAULT_PORT
|
static java.lang.String |
LOCAL_HOST
|
static int |
TIMEOUT
|
Constructor Summary | |
TcpService()
Default Constructor connects to the local machine on the default port address. |
|
TcpService(java.net.Socket sock)
Constructor keeps socket reference, and initialises input output streams for the socket. |
|
TcpService(java.lang.String host,
int port)
Attempts to connect to the given host on the given port address. |
Method Summary | |
void |
close()
Close the socket connection, and perform any necessary cleanup. |
java.net.Socket |
getSocket()
Return the socket reference. |
java.lang.Object |
receive()
An object is received on the socket. |
void |
send(java.io.Serializable ob)
Send the specified object. |
java.lang.String |
toString()
Retrieve a unique id for this connection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int TIMEOUT
public static final java.lang.String LOCAL_HOST
public static final int DEFAULT_PORT
Constructor Detail |
public TcpService() throws java.rmi.UnknownHostException, java.io.IOException
public TcpService(java.lang.String host, int port) throws java.rmi.UnknownHostException, java.io.IOException
host
- The host to connect to.port
- The port to connect on.
TcpConnectionError
- if the connection fails.
java.rmi.UnknownHostException
java.io.IOException
public TcpService(java.net.Socket sock) throws java.io.IOException
sock
- The socket to monitor.Method Detail |
public java.net.Socket getSocket()
public void close() throws java.io.IOException
close
in interface IpcIfc
java.io.IOException
- If the socket encounters an error.public void send(java.io.Serializable ob) throws java.io.IOException
send
in interface IpcIfc
ob
- The object to send. Must be serializable.
java.io.IOException
- If the data fails to write to the output stream.public java.lang.Object receive() throws java.io.IOException, java.lang.ClassNotFoundException
receive
in interface IpcIfc
java.io.IOException
- If the data cannot be received.
java.lang.ClassNotFoundException
- If the class cannot be re-constituted.public java.lang.String toString()
toString
in interface IpcIfc
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |