public class TCPConnectionMap.TCPConnection extends java.lang.Object implements Connection
| 限定符和类型 | 类和说明 |
|---|---|
protected class |
TCPConnectionMap.TCPConnection.Receiver |
protected class |
TCPConnectionMap.TCPConnection.Sender |
| 限定符和类型 | 字段和说明 |
|---|---|
protected byte[] |
cookie |
protected java.io.DataInputStream |
in |
protected long |
last_access |
protected java.io.DataOutputStream |
out |
protected Address |
peer_addr |
protected TCPConnectionMap.TCPConnection.Receiver |
receiver |
protected java.util.concurrent.locks.ReentrantLock |
send_lock |
protected TCPConnectionMap.TCPConnection.Sender |
sender |
protected java.net.Socket |
sock |
| 构造器和说明 |
|---|
TCPConnectionMap.TCPConnection(Address peer_addr)
Creates a connection stub and binds it, use
connect(java.net.SocketAddress) to connect |
TCPConnectionMap.TCPConnection(java.net.Socket s) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
_send(byte[] data,
int offset,
int length,
boolean acquire_lock,
boolean flush)
Sends data using the 'out' output stream of the socket
|
void |
close() |
protected void |
connect(java.net.SocketAddress destAddr)
Called after
TCPConnection#TCPConnection(Address) |
protected void |
doSend(byte[] data,
int offset,
int length,
boolean acquire_lock,
boolean flush) |
protected void |
flush() |
protected Address |
getPeerAddress() |
protected java.lang.String |
getSockAddress() |
protected long |
getTimestamp() |
boolean |
isConnected() |
boolean |
isExpired(long now) |
boolean |
isOpen() |
protected boolean |
isSenderUsed() |
protected boolean |
matchCookie(byte[] input) |
protected Address |
readPeerAddress(java.net.Socket client_sock)
Reads the peer's address.
|
protected void |
send(byte[] data,
int offset,
int length) |
protected void |
sendLocalAddress(Address local_addr)
Send the cookie first, then the our port number.
|
protected TCPConnectionMap.TCPConnection |
start(ThreadFactory f) |
java.lang.String |
toString() |
protected void |
updateLastAccessed() |
protected final java.net.Socket sock
protected final java.util.concurrent.locks.ReentrantLock send_lock
protected final byte[] cookie
protected java.io.DataOutputStream out
protected java.io.DataInputStream in
protected Address peer_addr
protected long last_access
protected TCPConnectionMap.TCPConnection.Sender sender
protected TCPConnectionMap.TCPConnection.Receiver receiver
public TCPConnectionMap.TCPConnection(Address peer_addr) throws java.lang.Exception
connect(java.net.SocketAddress) to connectjava.lang.Exceptionpublic TCPConnectionMap.TCPConnection(java.net.Socket s)
throws java.lang.Exception
java.lang.Exceptionprotected long getTimestamp()
protected Address getPeerAddress()
protected boolean isSenderUsed()
protected java.lang.String getSockAddress()
protected void updateLastAccessed()
protected void connect(java.net.SocketAddress destAddr)
throws java.lang.Exception
TCPConnection#TCPConnection(Address)java.lang.Exceptionprotected TCPConnectionMap.TCPConnection start(ThreadFactory f)
protected void send(byte[] data,
int offset,
int length)
throws java.lang.Exception
data - Guaranteed to be non nulloffset - length - java.lang.Exceptionprotected void _send(byte[] data,
int offset,
int length,
boolean acquire_lock,
boolean flush)
throws java.lang.Exception
data - offset - length - acquire_lock - java.lang.Exceptionprotected void doSend(byte[] data,
int offset,
int length,
boolean acquire_lock,
boolean flush)
throws java.lang.Exception
java.lang.Exceptionprotected void flush()
throws java.lang.Exception
java.lang.Exceptionprotected Address readPeerAddress(java.net.Socket client_sock) throws java.lang.Exception
java.lang.Exceptionprotected void sendLocalAddress(Address local_addr) throws java.lang.Exception
java.lang.Exceptionprotected boolean matchCookie(byte[] input)
public java.lang.String toString()
toString 在类中 java.lang.Objectpublic boolean isExpired(long now)
isExpired 在接口中 Connectionpublic boolean isConnected()
public boolean isOpen()
isOpen 在接口中 Connectionpublic void close()
throws java.io.IOException
close 在接口中 Connectionclose 在接口中 java.io.Closeableclose 在接口中 java.lang.AutoCloseablejava.io.IOException