public abstract class NIONetSocketBase extends NetSocketBase implements NetSocket
NetSocket.NetSocketFactory| Modifier and Type | Field and Description |
|---|---|
protected java.nio.channels.SocketChannel |
channel
Underlying SocketChannel instance
|
LOG, TRACE_LMBUF_SIZE, FACTORY, handshakeTimeout, LOG| Constructor and Description |
|---|
NIONetSocketBase(java.nio.channels.SocketChannel channel)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the socket.
|
java.net.InetAddress |
getLocalAddr()
Access the address of the local system, through which we are connecting.
|
java.net.InetSocketAddress |
getLocalSockAddr()
Access the address of the local system, through which we are connecting.
|
protected int |
getMaxMessageSize()
Get maximal message size
|
java.net.InetAddress |
getRemoteAddr()
Access the address of the remote system, to which we are connecting.
|
java.net.InetSocketAddress |
getRemoteSockAddr()
Access the address of the remote system, to which we are connecting.
|
boolean |
isClosed()
Reports if the socket is closed (and thus can no longer be used).
|
byte[] |
read()
Read the next portion of raw data (byte array) to the output
|
boolean |
readBoolean()
Read the boolean from the input
|
void |
readBytes(byte[] bytes)
Read the byte sequence from the input
|
protected abstract byte[] |
readFully()
Read next data chunk from the channel
|
int |
readInt()
Read the integer from the input
|
java.lang.String |
readUTF()
Read the UTF string from the input
|
void |
write(byte[] data)
Write byte array to the output
|
protected abstract void |
write(java.nio.ByteBuffer bb)
Send the data to the channel
|
void |
writeBoolean(boolean val)
Write a boolean to the output
|
void |
writeBytes(byte[] bytes)
Write a byte sequence to the output
|
void |
writeInt(int val)
Write an integer to the output
|
void |
writeUTF(java.lang.String val)
Write an UTF String to the output
|
addSessionListener, getSessionListenersclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddSessionListener, flush, getSession, getSessionListeners, tracef, tracelnprotected final java.nio.channels.SocketChannel channel
NIONetSocketBase(java.nio.channels.SocketChannel channel)
throws java.io.IOException
channel - underlying SocketChannel instancejava.io.IOException - on errorpublic boolean isClosed()
public java.net.InetAddress getLocalAddr()
getLocalAddr in interface NetSocketpublic java.net.InetSocketAddress getLocalSockAddr()
getLocalSockAddr in interface NetSocketpublic java.net.InetAddress getRemoteAddr()
getRemoteAddr in interface NetSocketpublic java.net.InetSocketAddress getRemoteSockAddr()
getRemoteSockAddr in interface NetSocketpublic void write(byte[] data)
throws java.io.IOException
public byte[] read()
throws java.io.IOException
public int readInt()
throws java.io.IOException
public void writeInt(int val)
throws java.io.IOException
public void readBytes(byte[] bytes)
throws java.io.IOException
public void writeBytes(byte[] bytes)
throws java.io.IOException
writeBytes in interface NetSocketbytes - byte sequence to be writtenjava.io.IOException - on errorpublic boolean readBoolean()
throws java.io.IOException
readBoolean in interface NetSocketjava.io.IOException - on errorpublic void writeBoolean(boolean val)
throws java.io.IOException
writeBoolean in interface NetSocketval - boolean data to be writtenjava.io.IOException - on errorpublic java.lang.String readUTF()
throws java.io.IOException
public void writeUTF(java.lang.String val)
throws java.io.IOException
protected abstract void write(java.nio.ByteBuffer bb)
throws java.io.IOException
bb - data to be sentjava.io.IOException - on errorprotected abstract byte[] readFully()
throws java.io.IOException,
java.io.EOFException
java.io.IOException - on errorjava.io.EOFException - if no data can be readprotected int getMaxMessageSize()