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_LM
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, getSessionListeners
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addSessionListener, flush, getSession, getSessionListeners, tracef, traceln
protected 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 NetSocket
public java.net.InetSocketAddress getLocalSockAddr()
getLocalSockAddr
in interface NetSocket
public java.net.InetAddress getRemoteAddr()
getRemoteAddr
in interface NetSocket
public java.net.InetSocketAddress getRemoteSockAddr()
getRemoteSockAddr
in interface NetSocket
public 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 NetSocket
bytes
- byte sequence to be writtenjava.io.IOException
- on errorpublic boolean readBoolean() throws java.io.IOException
readBoolean
in interface NetSocket
java.io.IOException
- on errorpublic void writeBoolean(boolean val) throws java.io.IOException
writeBoolean
in interface NetSocket
val
- 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()