public final class TcpIpConnection extends Object implements Connection
Connection.
A Connection has 2 sides:
ReadHandler and the writing side of this connection
is the WriteHandler.| Constructor and Description |
|---|
TcpIpConnection(TcpIpConnectionManager connectionManager,
IOSelector in,
IOSelector out,
int connectionId,
SocketChannelWrapper socketChannel) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this connection.
|
void |
close(Throwable t) |
boolean |
equals(Object o) |
int |
getConnectionId() |
TcpIpConnectionManager |
getConnectionManager() |
Address |
getEndPoint()
Gets the
Address of the other side of this Connection. |
InetAddress |
getInetAddress()
Returns remote address of this Connection.
|
TcpIpConnectionMonitor |
getMonitor() |
int |
getPort()
The remote port.
|
ReadHandler |
getReadHandler() |
InetSocketAddress |
getRemoteSocketAddress()
Returns the address of the endpoint this Connection is connected to, or
null if it is unconnected. |
SocketChannelWrapper |
getSocketChannelWrapper() |
ConnectionType |
getType()
Returns the
ConnectionType of this Connection. |
WriteHandler |
getWriteHandler() |
int |
hashCode() |
boolean |
isAlive()
Checks if the Connection is still alive.
|
boolean |
isClient()
Checks if it is a client connection.
|
long |
lastReadTime()
Returns the clock time of the most recent read using this connection.
|
long |
lastWriteTime()
Returns the clock time of the most recent write using this connection.
|
void |
setEndPoint(Address endPoint) |
void |
setMonitor(TcpIpConnectionMonitor monitor) |
void |
setReceiveBufferSize(int size) |
void |
setSendBufferSize(int size) |
void |
setType(ConnectionType type) |
void |
start()
Starts this connection.
|
String |
toString() |
boolean |
write(SocketWritable packet)
Writes a SocketWritable packet to the other side.
|
public TcpIpConnection(TcpIpConnectionManager connectionManager, IOSelector in, IOSelector out, int connectionId, SocketChannelWrapper socketChannel)
public void start()
public ConnectionType getType()
ConnectionConnectionType of this Connection.getType in interface Connectionnull is returned.public TcpIpConnectionManager getConnectionManager()
public boolean write(SocketWritable packet)
Connectionwrite in interface Connectionpacket - the packet to write.public boolean isClient()
ConnectionisClient in interface Connectionpublic void setType(ConnectionType type)
public SocketChannelWrapper getSocketChannelWrapper()
public InetAddress getInetAddress()
ConnectiongetInetAddress in interface Connectionnull if the connection is not alive.public int getPort()
ConnectiongetPort in interface Connectionpublic InetSocketAddress getRemoteSocketAddress()
Connectionnull if it is unconnected.getRemoteSocketAddress in interface Connectionpublic ReadHandler getReadHandler()
public WriteHandler getWriteHandler()
public boolean isAlive()
ConnectionisAlive in interface Connectionpublic long lastWriteTime()
ConnectionlastWriteTime in interface Connectionpublic long lastReadTime()
ConnectionlastReadTime in interface Connectionpublic Address getEndPoint()
ConnectionAddress of the other side of this Connection.
todo: rename to get remoteAddress?getEndPoint in interface Connectionpublic void setEndPoint(Address endPoint)
public void setMonitor(TcpIpConnectionMonitor monitor)
public TcpIpConnectionMonitor getMonitor()
public void close()
Connectionclose in interface Connectionpublic void close(Throwable t)
public int getConnectionId()
public void setSendBufferSize(int size)
throws SocketException
SocketExceptionpublic void setReceiveBufferSize(int size)
throws SocketException
SocketExceptionCopyright © 2015 Hazelcast, Inc.. All Rights Reserved.