Package eu.tneitzel.rmg.networking
Class DGCClientSocket
- java.lang.Object
-
- java.net.Socket
-
- eu.tneitzel.rmg.networking.DGCClientSocket
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DGCClientSocket extends Socket
The DGCClientSocket simulates a connection to the DGC server side component of a remote object. All output that is written to the socket is dropped. When input is read from the socket, it returns a static DGC response that contains an invalid class (an Integer that violates the DGC deserialization filter). The standard behavior for the DGC is to give up on DGC calls when an invalid class is encountered. An alternative is to return a long living Lease. Currently where is only one use case in remote-method-guesser for this class that should create at maximum one DGC connection per remote endpoint. The implementation in this class is not suitable for connection reuse. If connections are reused, the DGC will encounter errors, since the static response always contains a full RMI handshake. In the current state this should never occur and even if it occurs, it shouldn't impact the user experience as DGC exceptions are handled hidden from the user. If reuse of connections is required in future, you may want to add a more sophisticated connection handling in this class, which checks whether a connection is newly created or being reused.- Author:
- Tobias Neitzel (@qtc_de)
-
-
Constructor Summary
Constructors Constructor Description DGCClientSocket(String host, int port)Create a new DGCClientSocket.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStreamgetInputStream()Simulates an InputStream that is connected to the DGC component of an RMI server.OutputStreamgetOutputStream()Simulate an OutputStream that is connected to the DGC component of an RMI server.-
Methods inherited from class java.net.Socket
bind, close, connect, connect, getChannel, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOption, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setOption, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, supportedOptions, toString
-
-
-
-
Constructor Detail
-
DGCClientSocket
public DGCClientSocket(String host, int port)
Create a new DGCClientSocket.- Parameters:
host- remote hostport- remote port
-
-
Method Detail
-
getInputStream
public InputStream getInputStream() throws IOException
Simulates an InputStream that is connected to the DGC component of an RMI server. Always returns the same static response, which is the result of a DGC.dirty call. Instead of returning a Lease, we return an Integer, which triggers the deserialization filter of the DGC component and prevents remote references from being registered on the runtime.- Overrides:
getInputStreamin classSocket- Throws:
IOException
-
getOutputStream
public OutputStream getOutputStream()
Simulate an OutputStream that is connected to the DGC component of an RMI server. Instead of sending data, the output stream drops anything that is put into it.- Overrides:
getOutputStreamin classSocket
-
-