public interface NetSocket
Modifier and Type | Interface and Description |
---|---|
static interface |
NetSocket.NetSocketFactory
NetSocket factory
|
Modifier and Type | Field and Description |
---|---|
static int |
BUF_SIZE
I/O buffers' size
|
static NetSocket.NetSocketFactory |
FACTORY
NetSocket factory instance
|
static long |
handshakeTimeout
Handshake timeout (ms)
|
static java.util.logging.Logger |
LOG
Logger
|
static boolean |
TRACE
Trace network operations' flag
|
Modifier and Type | Method and Description |
---|---|
void |
addSessionListener(SessionListener sessionListener)
Adds a session listener.
|
void |
close()
Closes the socket.
|
default void |
flush()
Flush the output if applicable
|
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.
|
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.
|
javax.net.ssl.SSLSession |
getSession()
Gets the SSL session.
|
java.util.List<SessionListener> |
getSessionListeners()
Gets the list with added session listeners.
|
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
|
int |
readInt()
Read the integer from the input
|
java.lang.String |
readUTF()
Read the UTF string from the input
|
default void |
tracef(java.lang.String fmt,
java.lang.Object... args)
Write a message to the log using the specified format string and
arguments.
|
default void |
traceln(java.lang.String message)
Write message to the log
|
void |
write(byte[] data)
Write byte array to the output
|
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
|
static final java.util.logging.Logger LOG
static final long handshakeTimeout
static final int BUF_SIZE
static final boolean TRACE
static final NetSocket.NetSocketFactory FACTORY
default void traceln(java.lang.String message)
message
- message to be writtendefault void tracef(java.lang.String fmt, java.lang.Object... args)
fmt
- A format stringargs
- Arguments referenced by the format specifiers in the format
string.javax.net.ssl.SSLSession getSession()
null
if the socket is not
secure.void close()
boolean isClosed()
true
if the socket is closed.java.net.InetAddress getLocalAddr()
java.net.InetSocketAddress getLocalSockAddr()
java.net.InetAddress getRemoteAddr()
java.net.InetSocketAddress getRemoteSockAddr()
java.util.List<SessionListener> getSessionListeners()
null
if none has
been added.void addSessionListener(SessionListener sessionListener)
sessionListener
- A session listener to be added.default void flush() throws java.io.IOException
java.io.IOException
- on errorvoid write(byte[] data) throws java.io.IOException
data
- byte arrayjava.io.IOException
- on errorbyte[] read() throws java.io.IOException
java.io.IOException
- on errorint readInt() throws java.io.IOException
java.io.IOException
- on errorvoid writeInt(int val) throws java.io.IOException
val
- integer data to be writtenjava.io.IOException
- on errorvoid writeBytes(byte[] bytes) throws java.io.IOException
bytes
- byte sequence to be writtenjava.io.IOException
- on errorvoid readBytes(byte[] bytes) throws java.io.IOException
bytes
- byte array to be filled by the input bytesjava.io.IOException
- on errorvoid writeBoolean(boolean val) throws java.io.IOException
val
- boolean data to be writtenjava.io.IOException
- on errorboolean readBoolean() throws java.io.IOException
java.io.IOException
- on errorjava.lang.String readUTF() throws java.io.IOException
java.io.IOException
- on errorvoid writeUTF(java.lang.String val) throws java.io.IOException
val
- UTF String to be writtenjava.io.IOException
- on error