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.Exceptionpublic NioConnection(java.nio.channels.SocketChannel channel,
NioBaseServer server)
throws java.lang.Exception
java.lang.Exceptionpublic boolean isOpen()
isOpen in class Connectionpublic boolean isConnected()
isConnected in class Connectionpublic boolean isConnectionPending()
isConnectionPending in class Connectionpublic boolean isExpired(long now)
isExpired in class Connectionprotected void updateLastAccessed()
public Address localAddress()
localAddress in class Connectionpublic Address peerAddress()
peerAddress in class Connectionpublic 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 Connectionjava.lang.Exceptionprotected void connect(Address dest, boolean send_local_addr) throws java.lang.Exception
java.lang.Exceptionpublic void start()
throws java.lang.Exception
start in class Connectionjava.lang.Exceptionpublic void send(byte[] buf,
int offset,
int length)
throws java.lang.Exception
send in class Connectionjava.lang.Exceptionpublic void send(java.nio.ByteBuffer buf)
throws java.lang.Exception
send in class Connectionbuf - java.lang.Exceptionpublic void send()
throws java.lang.Exception
java.lang.Exceptionpublic void receive()
throws java.lang.Exception
java.lang.Exceptionprotected void send(java.nio.ByteBuffer buf,
boolean send_length)
throws java.lang.Exception
java.lang.Exceptionprotected boolean _receive(boolean update)
throws java.lang.Exception
java.lang.Exceptionpublic void close()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String status()
status in class Connectionprotected long getTimestamp()
protected void writeInterest(boolean register)
protected void setSocketParameters(java.net.Socket client_sock)
throws java.net.SocketException
java.net.SocketExceptionprotected void sendLocalAddress(Address local_addr) throws java.lang.Exception
java.lang.Exceptionprotected Address readPeerAddress() throws java.lang.Exception
java.lang.Exceptionprotected 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.