|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectasynctcp.Connection
public abstract class Connection
An interface shared by all connections, both locally and remotely established.
Nested Class Summary | |
---|---|
static class |
Connection.ConnectionState
An enumeration over all possible connection states. |
Method Summary | |
---|---|
java.lang.Object |
attach(java.lang.Object obj)
Attaches the given object to this connection. |
java.lang.Object |
attachment()
Retrieves the attachment for this connection. |
Connection.ConnectionState |
disconnect()
Attempts to close this connection if it is not closing or closed already. |
Connection.ConnectionState |
getConnectionState()
Returns the current state of this connection. |
ConnectionListener |
getListener()
Retrieves the listener for this connection. |
ASyncTCPMessageQueue |
getMessageQueue()
Returns the MessageQueue object associated with this
connection. |
AddressPortPair |
getRemoteHost()
Returns the IP address and port number at which this connection terminates. |
abstract boolean |
isLocalConnection()
Returns whether this connection was locally or remotely established. |
abstract Connection.ConnectionState |
reconnect(long timeout_ms)
If this connection was established locally, meaning isLocalConnection returns true , then this
method attempts to reestablish the connection. |
ConnectionListener |
setListener(ConnectionListener _cl)
Sets cl as the listener on this connection. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public AddressPortPair getRemoteHost()
null
is
returned.
public java.lang.Object attach(java.lang.Object obj)
attachment
method. Only one
object may be attached at a time; invoking this method causes any
previous attachment to be discarded. The current attachment may be
discarded by attaching null
.
obj
- the object to be attached; may be null
null
public java.lang.Object attachment()
null
if there is no attachmentpublic Connection.ConnectionState getConnectionState()
public Connection.ConnectionState disconnect()
DISCONNECTING
or DISCONNECTED
, then
invoking this method has no effect. If the current state is
CONNECTING
, then the connection attempt is cancelled
immdiately. If the current state is CONNECTED
, then this
connection enters the DISCONNECTING
state until all
enqueued messages are sent.
public abstract Connection.ConnectionState reconnect(long timeout_ms)
isLocalConnection
returns true
, then this
method attempts to reestablish the connection. If the connection state is
currently DISCONNECTING
because the queue of this
connection is still being emptied, then invoking this method cancels the
disconnect and returns the state to CONNECTED
. If the
connection state is currently DISCONNECTED
, then this
method will begin establishing a new connection entirely, and change the
connection state to CONNECTING
. In any other state,
invoking this method has no effect.
If this connection was established remotely, and has a state of
DISCONNECTING
because it is still emptying its message
queue, then invoking this method simply cancels the disconnect and
returns the state to CONNECTED
. In any other state,
invoking this method has no effect.
timeout_ms
- the maximum amount of time, in milliseconds, before it is assumed that
the connection attempt has failed
public abstract boolean isLocalConnection()
true
if this connection was locally established,
false
otherwisepublic ASyncTCPMessageQueue getMessageQueue()
MessageQueue
object associated with this
connection.
public ConnectionListener getListener()
null
if there is no listenerpublic ConnectionListener setListener(ConnectionListener _cl)
cl
as the listener on this connection. The listener
can later be retrieved via the getListener
method. Only
one listener may be set at a time; invoking this method causes any
previous listener to be discarded. The current listener may be discarded
by passing in null
.
_cl
- the new listener for this connection
null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |