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 boolean |
connected |
protected java.io.DataInputStream |
in |
protected java.io.DataOutputStream |
out |
protected TcpConnection.Receiver |
receiver |
protected java.util.concurrent.locks.ReentrantLock |
send_lock |
protected TcpConnection.Sender |
sender |
protected TcpBaseServer |
server |
protected java.net.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(java.net.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 java.lang.String |
getSockAddress() |
protected long |
getTimestamp() |
boolean |
isConnected() |
boolean |
isConnectionPending() |
boolean |
isExpired(long now) |
boolean |
isOpen() |
protected boolean |
isSenderUsed() |
Address |
localAddress() |
Address |
peerAddress() |
protected Address |
readPeerAddress(java.net.Socket client_sock)
Reads the peer's address.
|
void |
send(byte[] data,
int offset,
int length) |
void |
send(java.nio.ByteBuffer buf) |
protected void |
sendLocalAddress(Address local_addr)
Send the cookie first, then the our port number.
|
protected void |
setSocketParameters(java.net.Socket client_sock) |
void |
start() |
java.lang.String |
status() |
java.lang.String |
toString() |
protected void |
updateLastAccessed() |
protected final java.net.Socket sock
protected final java.util.concurrent.locks.ReentrantLock send_lock
protected static final Buffer termination
protected java.io.DataOutputStream out
protected java.io.DataInputStream in
protected volatile TcpConnection.Sender sender
protected volatile TcpConnection.Receiver receiver
protected final TcpBaseServer server
protected boolean connected
public TcpConnection(Address peer_addr, TcpBaseServer server) throws java.lang.Exception
connect(Address)
to connectjava.lang.Exception
public TcpConnection(java.net.Socket s, TcpServer server) throws java.lang.Exception
java.lang.Exception
public Address localAddress()
localAddress
in class Connection
public Address peerAddress()
peerAddress
in class Connection
protected long getTimestamp()
protected boolean isSenderUsed()
protected java.lang.String getSockAddress()
protected void updateLastAccessed()
public void connect(Address dest) throws java.lang.Exception
connect
in class Connection
java.lang.Exception
protected void connect(Address dest, boolean send_local_addr) throws java.lang.Exception
java.lang.Exception
public void start()
start
in class Connection
public void send(byte[] data, int offset, int length) throws java.lang.Exception
send
in class Connection
data
- Guaranteed to be non nulloffset
- length
- java.lang.Exception
public void send(java.nio.ByteBuffer buf) throws java.lang.Exception
send
in class Connection
java.lang.Exception
protected void _send(byte[] data, int offset, int length, boolean acquire_lock, boolean flush) throws java.lang.Exception
data
- offset
- length
- acquire_lock
- java.lang.Exception
protected void doSend(byte[] data, int offset, int length, boolean acquire_lock, boolean flush) throws java.lang.Exception
java.lang.Exception
protected void flush() throws java.lang.Exception
java.lang.Exception
protected void setSocketParameters(java.net.Socket client_sock) throws java.net.SocketException
java.net.SocketException
protected void sendLocalAddress(Address local_addr) throws java.lang.Exception
java.lang.Exception
protected Address readPeerAddress(java.net.Socket client_sock) throws java.lang.Exception
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String status()
status
in class Connection
public boolean isExpired(long now)
isExpired
in class Connection
public boolean isConnected()
isConnected
in class Connection
public boolean isConnectionPending()
isConnectionPending
in class Connection
public boolean isOpen()
isOpen
in class Connection
public void close() throws java.io.IOException
java.io.IOException
Copyright © 1998-2020 Red Hat. All Rights Reserved.