public class TcpConnection extends Connection
BaseServer.receive(Address,byte[],int,int) when data has been received.| Modifier and Type | Class and Description |
|---|---|
protected class |
TcpConnection.Receiver |
protected class |
TcpConnection.Sender |
| Modifier and Type | Field and Description |
|---|---|
protected DataInputStream |
in |
protected DataOutputStream |
out |
protected TcpConnection.Receiver |
receiver |
protected ReentrantLock |
send_lock |
protected TcpConnection.Sender |
sender |
protected TcpBaseServer |
server |
protected Socket |
sock |
protected static Buffer |
termination |
cookie, last_access, peer_addr| Constructor and Description |
|---|
TcpConnection(Address peer_addr,
TcpBaseServer server)
Creates a connection stub and binds it, use
connect(Address) to connect |
TcpConnection(Socket s,
TcpServer server) |
| Modifier and Type | Method and Description |
|---|---|
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() |
void |
connect(Address dest) |
protected void |
connect(Address dest,
boolean send_local_addr) |
protected void |
doSend(byte[] data,
int offset,
int length,
boolean acquire_lock,
boolean flush) |
protected void |
flush() |
protected String |
getSockAddress() |
protected long |
getTimestamp() |
boolean |
isConnected() |
boolean |
isExpired(long now) |
boolean |
isOpen() |
protected boolean |
isSenderUsed() |
Address |
localAddress() |
Address |
peerAddress() |
protected Address |
readPeerAddress(Socket client_sock)
Reads the peer's address.
|
void |
send(byte[] data,
int offset,
int length) |
void |
send(ByteBuffer buf) |
protected void |
sendLocalAddress(Address local_addr)
Send the cookie first, then the our port number.
|
protected void |
setSocketParameters(Socket client_sock) |
void |
start() |
protected String |
status() |
String |
toString() |
protected void |
updateLastAccessed() |
protected final Socket sock
protected final ReentrantLock send_lock
protected static final Buffer termination
protected DataOutputStream out
protected DataInputStream in
protected volatile TcpConnection.Sender sender
protected volatile TcpConnection.Receiver receiver
protected final TcpBaseServer server
public TcpConnection(Address peer_addr, TcpBaseServer server) throws Exception
connect(Address) to connectExceptionpublic Address localAddress()
localAddress in class Connectionpublic Address peerAddress()
peerAddress in class Connectionprotected long getTimestamp()
protected boolean isSenderUsed()
protected String getSockAddress()
protected void updateLastAccessed()
public void connect(Address dest) throws Exception
connect in class ConnectionExceptionprotected void connect(Address dest, boolean send_local_addr) throws Exception
Exceptionpublic void start()
start in class Connectionpublic void send(byte[] data,
int offset,
int length)
throws Exception
send in class Connectiondata - Guaranteed to be non nulloffset - length - Exceptionpublic void send(ByteBuffer buf) throws Exception
send in class ConnectionExceptionprotected void _send(byte[] data,
int offset,
int length,
boolean acquire_lock,
boolean flush)
throws Exception
data - offset - length - acquire_lock - Exceptionprotected void doSend(byte[] data,
int offset,
int length,
boolean acquire_lock,
boolean flush)
throws Exception
Exceptionprotected void setSocketParameters(Socket client_sock) throws SocketException
SocketExceptionprotected void sendLocalAddress(Address local_addr) throws Exception
Exceptionprotected Address readPeerAddress(Socket client_sock) throws Exception
Exceptionprotected String status()
public boolean isExpired(long now)
isExpired in class Connectionpublic boolean isConnected()
isConnected in class Connectionpublic boolean isOpen()
isOpen in class Connectionpublic void close()
throws IOException
IOExceptionCopyright © 2025 JBoss, a division of Red Hat. All rights reserved.