public class SocketTransport extends java.lang.Object implements TransportI, javax.net.ssl.HandshakeCompletedListener
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_ALIVE_CHECK_INTERVAL |
static org.apache.log4j.Logger |
log |
static java.util.Timer |
SOCKET_TEST_TIMER |
| Constructor and Description |
|---|
SocketTransport(PooledSocket _pooledSocket,
java.lang.String _logstring)
Constructor for client-side: creates a new socket and initializes it using the passed BackendConnection.
|
SocketTransport(java.net.Socket _socket,
java.lang.String _logstring)
Constructor for server-side: we already have a socket at hand.
|
| Modifier and Type | Method and Description |
|---|---|
void |
aboutToListen()
Sets this TransportI to a listening mode, which will not send any keep-alives nor enforce timeouts.
|
void |
aboutToSend()
Sets this TransportI to a sending mode, which will send keep-alives and enforce timeouts.
|
void |
authenticated(boolean b,
int _pid)
Sets the authenticated-state and the pid for this TransportI (after login).
|
boolean |
canReconnect()
Returns true, if this TransportI can reconnect.
|
void |
close()
Closes this TransportI, possibly raising an IO-Exception that may have been signalled during closing.
|
void |
closeLater() |
void |
closeNT()
Closes this TransportI silently.
|
CryptoHandlerI |
getCryptoHandler()
Retrieves a
CryptoHandlerI object from the
BackendProtocolServer. |
java.lang.String |
getGateway(java.lang.String claddr,
java.lang.String clport)
Returns a String representation of the gateway of this TransportI (if any).
|
SecureObjectInputI |
getIn()
Exposes the underlying SecureObjectInputI.
|
int |
getKeepAliveInterval()
Returns the current keep-alive interval of the underlying output or -1 if no keep-alive is possible or active there.
|
java.lang.String |
getLocalHostAddress()
Returns the host address for the local part of the connection.
|
java.lang.String |
getLocalPort()
Returns the port for the local part of the connection.
|
java.lang.String |
getName()
Returns an identifier for this TransportI.
|
SecureObjectOutputI |
getOut()
Exposes the underlying SecureObjectOutputI.
|
int |
getPid()
Returns the pid that was assigned by the server-side.
|
java.lang.String |
getRemoteHostAddress()
Returns the host address for the remote part of the connection.
|
java.lang.String |
getRemotePort()
Returns the port for the remote part of the connection.
|
java.lang.String |
getServerEndpoint()
Returns a String representation of the server-endpoint of this TransportI.
|
java.lang.String |
getSubVersion()
Returns the protocol subversion, namely the additional parameters for the connection.
|
int |
getTimeout()
Returns the current connection-timeout or -1 if a TransportException occurred while getting that value.
|
void |
handshakeCompleted(javax.net.ssl.HandshakeCompletedEvent e)
Callback after a successful SSL-handshake as defined in interface
HandshakeCompletedListener. |
void |
initServerSide(BackendCommandHandlerI commandHandler,
BOLoaderI loader)
Initializes the protocol and the TransportI and creates input and output.
|
boolean |
isAuthenticated()
Returns true, if this TransportI is already associated with a session on the server.
|
boolean |
isClosed()
Returns true, if the underlying means of connection is closed, false otherwise.
|
boolean |
isLocalConnection()
Returns true if the connection comes and goes to the same interface
|
boolean |
isLoggedIn()
Returns true if the connection this TransportI is used in is in a logged-in state.
|
boolean |
isTotallyReliable()
Returns true if the connection doesn't need any keep-alive tests or similar monitoring
|
void |
readMagic()
Tries to read the defined protocol-magic from the input.
|
void |
readMagic(boolean updateLaseUsed)
Tries to read the defined protocol-magic from the input.
|
void |
reset()
Resets the underlying output.
|
void |
sendKeepAlive()
for non-totally-reliable socket connections, this will
immediately send some disregarded data to the other side,
which will fail in case the socket is somehow broken already.
|
void |
setKeepAliveInterval(int newInterval)
Sets the keep-alive interval of the output to the passed value.
|
int |
setTimeout(int t)
Sets the socket-timeout to the passed value in ms, 0 means no timeout
|
int |
testConnection()
Sends a test-command to the server and waits for the expected answer.
|
java.lang.String |
toString()
Returns a readable description of this TransportI.
|
public static final org.apache.log4j.Logger log
public static final java.util.Timer SOCKET_TEST_TIMER
public static final int DEFAULT_ALIVE_CHECK_INTERVAL
public SocketTransport(java.net.Socket _socket,
java.lang.String _logstring)
throws java.net.SocketException
java.net.SocketExceptionpublic SocketTransport(PooledSocket _pooledSocket, java.lang.String _logstring) throws java.io.IOException, FatalServerConnectionException
java.io.IOExceptionFatalServerConnectionExceptionpublic void reset()
throws java.io.IOException
TransportIreset in interface TransportIjava.io.IOExceptionpublic void close()
throws java.io.IOException
TransportIclose in interface TransportIjava.io.IOExceptionpublic void closeNT()
TransportIcloseNT in interface TransportIpublic void closeLater()
closeLater in interface TransportIpublic void initServerSide(BackendCommandHandlerI commandHandler, BOLoaderI loader) throws java.io.IOException, TransportException, IncompatibleProtocolException
TransportIinitServerSide in interface TransportIjava.io.IOExceptionTransportExceptionIncompatibleProtocolExceptionpublic java.lang.String getName()
TransportIgetName in interface TransportIpublic java.lang.String getServerEndpoint()
TransportIgetServerEndpoint in interface TransportIpublic java.lang.String getGateway(java.lang.String claddr,
java.lang.String clport)
TransportIgetGateway in interface TransportIpublic boolean isTotallyReliable()
TransportIisTotallyReliable in interface TransportIpublic boolean isLocalConnection()
TransportIisLocalConnection in interface TransportIpublic void sendKeepAlive()
throws java.io.IOException
java.io.IOExceptionpublic boolean isClosed()
TransportIisClosed in interface TransportIpublic boolean isAuthenticated()
TransportIisAuthenticated in interface TransportIpublic boolean isLoggedIn()
TransportIisLoggedIn in interface TransportIpublic boolean canReconnect()
TransportIcanReconnect in interface TransportIpublic SecureObjectInputI getIn()
TransportIgetIn in interface TransportIpublic SecureObjectOutputI getOut()
TransportIgetOut in interface TransportIpublic int getPid()
TransportIgetPid in interface TransportIpublic java.lang.String getSubVersion()
TransportIgetSubVersion in interface TransportIpublic java.lang.String getLocalHostAddress()
TransportIgetLocalHostAddress in interface TransportIpublic java.lang.String getLocalPort()
TransportIgetLocalPort in interface TransportIpublic java.lang.String getRemoteHostAddress()
public java.lang.String getRemotePort()
public java.lang.String toString()
TransportItoString in interface TransportItoString in class java.lang.Objectpublic void aboutToListen()
throws TransportException
TransportIaboutToListen in interface TransportITransportExceptionpublic void aboutToSend()
throws TransportException
TransportIaboutToSend in interface TransportITransportExceptionpublic int getTimeout()
TransportIgetTimeout in interface TransportIpublic int setTimeout(int t)
throws TransportException
setTimeout in interface TransportIt - an int specifying the new timeout for this TransportI in milliseconds,
0 means no timeoutTransportExceptionpublic int getKeepAliveInterval()
TransportIgetKeepAliveInterval in interface TransportIpublic void setKeepAliveInterval(int newInterval)
public void readMagic()
throws java.io.IOException
TransportIde.ipcon.db.ServerConnectionException if a timeout
occurred.readMagic in interface TransportIjava.io.IOExceptionpublic void readMagic(boolean updateLaseUsed)
throws java.io.IOException
TransportIde.ipcon.db.ServerConnectionException if a timeout
occurred.readMagic in interface TransportIupdateLaseUsed - a boolean defining if the last-used-timestamp
shall be updated upon reading the protocol-magicjava.io.IOExceptionpublic void authenticated(boolean b,
int _pid)
TransportIauthenticated in interface TransportIpublic CryptoHandlerI getCryptoHandler() throws ServerConnectionException
TransportICryptoHandlerI object from the
BackendProtocolServer.
Does not read a protocol-magic afterwards!
May signal a de.ipcon.db.FatalServerConnectionException if anything else than a
CryptoHandlerI was received from the server.
In case of errors the transport is closed.getCryptoHandler in interface TransportIServerConnectionExceptionpublic int testConnection()
throws ServerConnectionException
TransportItestConnection in interface TransportIServerConnectionExceptionpublic void handshakeCompleted(javax.net.ssl.HandshakeCompletedEvent e)
HandshakeCompletedListener.
Used for logging used protocol and cipher-suite and removing this PooledSocket as
HandshakeCompletedListener from the socket again.handshakeCompleted in interface javax.net.ssl.HandshakeCompletedListenerHandshakeCompletedListenerCopyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.