public class NetSocket
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.io.ObjectInputStream |
objectInp
Object input stream.
|
private java.io.ObjectOutputStream |
objectOut
Object output stream.
|
private javax.net.ssl.SSLSession |
session
SSL session.
|
private java.util.ArrayList<SessionListener> |
sessionListeners
Stores a list of
SessionListener s |
private java.net.Socket |
socket
Embedded socket which may or may not be secure.
|
Constructor and Description |
---|
NetSocket(java.net.Socket socket)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addSessionListener(SessionListener sessionListener)
Adds a session listener.
|
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.
|
java.io.ObjectInputStream |
getObjectInput()
Gets the object input stream.
|
java.io.ObjectOutputStream |
getObjectOutput()
Gets the object output stream.
|
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).
|
private java.net.Socket socket
private javax.net.ssl.SSLSession session
private java.io.ObjectInputStream objectInp
private java.io.ObjectOutputStream objectOut
private java.util.ArrayList<SessionListener> sessionListeners
SessionListener
spublic NetSocket(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()
null
if the socket is not
secure.public java.io.ObjectInputStream getObjectInput()
public java.io.ObjectOutputStream getObjectOutput()
public void close()
public boolean isClosed()
true
if the socket is closed.public java.net.InetAddress getLocalAddr()
public java.net.InetSocketAddress getLocalSockAddr()
public java.net.InetAddress getRemoteAddr()
public java.net.InetSocketAddress getRemoteSockAddr()
public java.util.List<SessionListener> getSessionListeners()
null
if none has
been added.public void addSessionListener(SessionListener sessionListener)
sessionListener
- A session listener to be added.