public class NioConnection extends Connection
Connection
Modifier and Type | Class and Description |
---|---|
protected class |
NioConnection.Reader |
protected static class |
NioConnection.State |
Modifier and Type | Field and Description |
---|---|
protected java.nio.channels.SocketChannel |
channel |
protected boolean |
connected |
protected boolean |
copy_on_partial_write |
protected java.nio.channels.SelectionKey |
key |
protected int |
partial_writes |
protected NioConnection.Reader |
reader |
protected long |
reader_idle_time |
protected Buffers |
recv_buf |
protected Buffers |
send_buf |
protected java.util.concurrent.locks.Lock |
send_lock |
protected NioBaseServer |
server |
protected boolean |
write_interest_set |
cookie, last_access, peer_addr
Constructor and Description |
---|
NioConnection(Address peer_addr,
NioBaseServer server)
Creates a connection stub and binds it, use
connect(Address) to connect |
NioConnection(java.nio.channels.SocketChannel channel,
NioBaseServer server) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
_receive(boolean update) |
void |
clearSelectionKey(int interest_ops) |
void |
close() |
void |
connect(Address dest) |
protected void |
connect(Address dest,
boolean send_local_addr) |
NioConnection |
connected(boolean c) |
boolean |
copyOnPartialWrite() |
NioConnection |
copyOnPartialWrite(boolean b) |
protected static byte[] |
getBuffer(java.nio.ByteBuffer buf) |
protected long |
getTimestamp() |
boolean |
isConnected() |
boolean |
isConnectionPending() |
boolean |
isExpired(long now) |
boolean |
isOpen() |
java.nio.channels.SelectionKey |
key() |
NioConnection |
key(java.nio.channels.SelectionKey k) |
Address |
localAddress() |
protected static java.nio.ByteBuffer |
makeLengthBuffer(java.nio.ByteBuffer buf) |
int |
numPartialWrites() |
Address |
peerAddress() |
long |
readerIdleTime() |
NioConnection |
readerIdleTime(long t) |
boolean |
readerRunning() |
protected Address |
readPeerAddress() |
void |
receive()
Read the length first, then the actual data.
|
void |
registerSelectionKey(int interest_ops) |
void |
send() |
void |
send(byte[] buf,
int offset,
int length) |
void |
send(java.nio.ByteBuffer buf)
Sends a message.
|
protected void |
send(java.nio.ByteBuffer buf,
boolean send_length) |
protected void |
sendLocalAddress(Address local_addr) |
protected void |
setSocketParameters(java.net.Socket client_sock) |
void |
start() |
java.lang.String |
status() |
java.lang.String |
toString() |
protected void |
updateLastAccessed() |
protected void |
writeInterest(boolean register) |
protected java.nio.channels.SocketChannel channel
protected java.nio.channels.SelectionKey key
protected final NioBaseServer server
protected final Buffers send_buf
protected boolean write_interest_set
protected boolean copy_on_partial_write
protected int partial_writes
protected final java.util.concurrent.locks.Lock send_lock
protected Buffers recv_buf
protected NioConnection.Reader reader
protected long reader_idle_time
protected boolean connected
public NioConnection(Address peer_addr, NioBaseServer server) throws java.lang.Exception
connect(Address)
to connectjava.lang.Exception
public NioConnection(java.nio.channels.SocketChannel channel, NioBaseServer server) throws java.lang.Exception
java.lang.Exception
public boolean isOpen()
isOpen
in class Connection
public boolean isConnected()
isConnected
in class Connection
public boolean isConnectionPending()
isConnectionPending
in class Connection
public boolean isExpired(long now)
isExpired
in class Connection
protected void updateLastAccessed()
public Address localAddress()
localAddress
in class Connection
public Address peerAddress()
peerAddress
in class Connection
public java.nio.channels.SelectionKey key()
public NioConnection key(java.nio.channels.SelectionKey k)
public NioConnection copyOnPartialWrite(boolean b)
public boolean copyOnPartialWrite()
public int numPartialWrites()
public long readerIdleTime()
public NioConnection readerIdleTime(long t)
public boolean readerRunning()
public NioConnection connected(boolean c)
public void registerSelectionKey(int interest_ops)
public void clearSelectionKey(int interest_ops)
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() throws java.lang.Exception
start
in class Connection
java.lang.Exception
public void send(byte[] buf, int offset, int length) throws java.lang.Exception
send
in class Connection
java.lang.Exception
public void send(java.nio.ByteBuffer buf) throws java.lang.Exception
send
in class Connection
buf
- java.lang.Exception
public void send() throws java.lang.Exception
java.lang.Exception
public void receive() throws java.lang.Exception
java.lang.Exception
protected void send(java.nio.ByteBuffer buf, boolean send_length) throws java.lang.Exception
java.lang.Exception
protected boolean _receive(boolean update) throws java.lang.Exception
java.lang.Exception
public void close() throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String status()
status
in class Connection
protected long getTimestamp()
protected void writeInterest(boolean register)
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() throws java.lang.Exception
java.lang.Exception
protected static byte[] getBuffer(java.nio.ByteBuffer buf)
protected static java.nio.ByteBuffer makeLengthBuffer(java.nio.ByteBuffer buf)
Copyright © 1998-2020 Red Hat. All Rights Reserved.