soc.server.genericServer
Interface StringConnection

All Known Implementing Classes:
Connection, LocalStringConnection

public interface StringConnection

StringConnection allows clients and servers to communicate, with no difference between local and actual networked traffic.

Author:
Jeremy D Monin
  1.0.0 - 2007-11-18 - initial release
  1.0.1 - 2008-06-28 - add getConnectTime
  1.0.2 - 2008-07-30 - no change in this file
  1.0.3 - 2008-08-08 - add disconnectSoft, getVersion, setVersion

Method Summary
 boolean connect()
          Start ability to read from the net; called only by the server.
 void disconnect()
          Close the socket, set EOF
 void disconnectSoft()
          Accept no further input, allow output to drain, don't immediately close the socket.
 java.util.Date getConnectTime()
           
 java.lang.Object getData()
           
 java.lang.Exception getError()
           
 int getVersion()
          Give the version number (if known) of the remote end of this connection.
 java.lang.String host()
           
 boolean isConnected()
          Are we currently connected and active?
 void put(java.lang.String str)
          Send data over the connection.
 void run()
          For server-side thread which reads and treats incoming messages
 void setData(java.lang.Object data)
          Set the app-specific data for this connection.
 void setVersion(int version)
          Set the version number of the remote end of this connection.
 

Method Detail

host

public java.lang.String host()
Returns:
Hostname of the remote end of the connection

put

public void put(java.lang.String str)
         throws java.lang.IllegalStateException
Send data over the connection.

Parameters:
str - Data to send
Throws:
java.lang.IllegalStateException - if not yet accepted by server

run

public void run()
For server-side thread which reads and treats incoming messages


isConnected

public boolean isConnected()
Are we currently connected and active?


connect

public boolean connect()
Start ability to read from the net; called only by the server. (In a network-based subclass, another thread may be started by this method.)

Returns:
true if able to connect, false if an error occurred.

disconnect

public void disconnect()
Close the socket, set EOF


disconnectSoft

public void disconnectSoft()
Accept no further input, allow output to drain, don't immediately close the socket. Once called, isConnected() will return false, even if output is still being sent to the other side.


getData

public java.lang.Object getData()
Returns:
The app-specific data for this connection.

setData

public void setData(java.lang.Object data)
Set the app-specific data for this connection. This is anything your application wants to associate with the connection. The StringConnection system itself does not reference or use this data.

Parameters:
data - The new data, or null

getError

public java.lang.Exception getError()
Returns:
Any error encountered, or null

getConnectTime

public java.util.Date getConnectTime()
Returns:
Time of connection to server, or of object creation if that time's not available
See Also:
connect()

getVersion

public int getVersion()
Give the version number (if known) of the remote end of this connection. The meaning of this number is application-defined.

Returns:
Version number, or 0 if unknown.

setVersion

public void setVersion(int version)
Set the version number of the remote end of this connection. The meaning of this number is application-defined.

Parameters:
version - Version number, or 0 if unknown.