public class NetSocketWrapper extends NetSocketBase implements NetSocket
NetSocket.NetSocketFactory
Modifier and Type | Field and Description |
---|---|
private java.io.DataInputStream |
dataInp
Data input stream.
|
private java.io.DataOutputStream |
dataOut
Data output stream.
|
private javax.net.ssl.SSLSession |
session
SSL session.
|
private java.net.Socket |
socket
Embedded socket which may or may not be secure.
|
LOG, TRACE_LM
Constructor and Description |
---|
NetSocketWrapper(java.net.Socket socket)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the socket.
|
void |
flush()
Flush the output
|
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.
|
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
|
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
|
addSessionListener, getSessionListeners
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addSessionListener, getSessionListeners, tracef, traceln
private final java.net.Socket socket
private final javax.net.ssl.SSLSession session
private final java.io.DataInputStream dataInp
private final java.io.DataOutputStream dataOut
public NetSocketWrapper(java.net.Socket socket) throws java.io.IOException
socket
- A connected socket to embed into this class. This may be a
secure socket but it is not required.java.io.IOException
- If one of the streams being built on top of the socket throws
the same exception.public javax.net.ssl.SSLSession getSession()
getSession
in interface NetSocket
null
if the socket is not
secure.public 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 flush() throws java.io.IOException
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 writeBytes(byte[] bytes) throws java.io.IOException
writeBytes
in interface NetSocket
bytes
- byte sequence to be writtenjava.io.IOException
- on errorpublic void readBytes(byte[] bytes) throws java.io.IOException
public void writeBoolean(boolean val) throws java.io.IOException
writeBoolean
in interface NetSocket
val
- boolean data to be writtenjava.io.IOException
- on errorpublic boolean readBoolean() throws java.io.IOException
readBoolean
in interface NetSocket
java.io.IOException
- on errorpublic java.lang.String readUTF() throws java.io.IOException