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 SocketChannel |
channel |
protected boolean |
copy_on_partial_write |
protected SelectionKey |
key |
protected int |
partial_writes |
protected NioConnection.Reader |
reader |
protected long |
reader_idle_time |
protected Buffers |
recv_buf |
protected Buffers |
send_buf |
protected 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(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) |
boolean |
copyOnPartialWrite() |
NioConnection |
copyOnPartialWrite(boolean b) |
protected static byte[] |
getBuffer(ByteBuffer buf) |
protected long |
getTimestamp() |
boolean |
isConnected() |
boolean |
isExpired(long now) |
boolean |
isOpen() |
SelectionKey |
key() |
NioConnection |
key(SelectionKey k) |
Address |
localAddress() |
protected static ByteBuffer |
makeLengthBuffer(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(ByteBuffer buf)
Sends a message.
|
protected void |
send(ByteBuffer buf,
boolean send_length) |
protected void |
sendLocalAddress(Address local_addr) |
protected void |
setSocketParameters(Socket client_sock) |
void |
start() |
protected String |
status() |
String |
toString() |
protected void |
updateLastAccessed() |
protected void |
writeInterest(boolean register) |
protected SocketChannel channel
protected 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 Lock send_lock
protected Buffers recv_buf
protected NioConnection.Reader reader
protected long reader_idle_time
public NioConnection(Address peer_addr, NioBaseServer server) throws Exception
connect(Address)
to connectException
public NioConnection(SocketChannel channel, NioBaseServer server) throws Exception
Exception
public boolean isOpen()
isOpen
in class Connection
public boolean isConnected()
isConnected
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 SelectionKey key()
public NioConnection key(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 void registerSelectionKey(int interest_ops)
public void clearSelectionKey(int interest_ops)
public void connect(Address dest) throws Exception
connect
in class Connection
Exception
protected void connect(Address dest, boolean send_local_addr) throws Exception
Exception
public void start() throws Exception
start
in class Connection
Exception
public void send(byte[] buf, int offset, int length) throws Exception
send
in class Connection
Exception
public void send(ByteBuffer buf) throws Exception
send
in class Connection
buf
- Exception
public void receive() throws Exception
Exception
protected void send(ByteBuffer buf, boolean send_length) throws Exception
Exception
public void close() throws IOException
IOException
protected String status()
protected long getTimestamp()
protected void writeInterest(boolean register)
protected void setSocketParameters(Socket client_sock) throws SocketException
SocketException
protected void sendLocalAddress(Address local_addr) throws Exception
Exception
protected static byte[] getBuffer(ByteBuffer buf)
protected static ByteBuffer makeLengthBuffer(ByteBuffer buf)
Copyright © 2022 JBoss, a division of Red Hat. All rights reserved.