|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.rmi.server.RMISocketFactory
twcsckernel.projectbase.rmi.socketfactory.ClientTwoWaySocketFactory
public class ClientTwoWaySocketFactory
Socket factory for clients who want servers to be able to call them back even if the client's address/port are not reachable from the server. This happens with firewalls and dial-up networking, for example.
The factory provides two main capabilities:
The gateway registry allows a mapping to be made between two endpoints. For example, the endpoint cssassociates.com:3453 can be mapped to somewhereElse.com:2356. Client connections made to the first endpoint from RMI will actually be connected to the second endpoint. This situation occurs when a port on a firewall is "opened" and forwarded to a host within the firewall.
A signalling channel is a socket from the client to the server and carries the "two-way" protocol (for lack of a better name). The client establishes a signalling channel to the server, which must be running the ServerTwoWaySocketFactory. When the server needs to make a callback to the client, it requests a socket via the channel instead of trying to directly connect to the client. The client establishes a socket to the server for the server to use in the callback.
Constructor Summary | |
---|---|
ClientTwoWaySocketFactory()
|
Method Summary | |
---|---|
java.net.ServerSocket |
createServerSocket(int port)
|
java.net.Socket |
createSocket(java.lang.String host,
int port)
Creates a socket to the specified host and
port . |
void |
establishSignallingChannel(java.lang.String address,
int port)
Establish a two-way protocol signalling channel to the server at
|
EndpointInfo |
getDirectEndpoint(java.lang.String host,
int port)
Returns the endpoint associated with the host
and port . |
void |
registerGateway(java.lang.String host,
int port,
java.lang.String gateHost,
int gatePort)
Register a gateway. |
Methods inherited from class java.rmi.server.RMISocketFactory |
---|
getDefaultSocketFactory, getFailureHandler, getSocketFactory, setFailureHandler, setSocketFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClientTwoWaySocketFactory()
Method Detail |
---|
public void registerGateway(java.lang.String host, int port, java.lang.String gateHost, int gatePort)
createSocket
for host:port
will
instead be made to gateHost:gatePort
host
- The destination host.port
- The destination port.gateHost
- The gateway host (proxy, firewall, etc.).gatePort
- The gateway port.public void establishSignallingChannel(java.lang.String address, int port) throws java.io.IOException
- Throws:
java.io.IOException
public EndpointInfo getDirectEndpoint(java.lang.String host, int port)
host
and port
. The endpoint returned is the endpoint
to be directly contacted. If the host
and
port
have an associated gateway endpoint, that
endpoint is returned. Otherwise an endpoint for the provided
host
and port
is returned.
public java.net.Socket createSocket(java.lang.String host, int port) throws java.io.IOException
host
and
port
. If a gateway has been registered using
registerGateway
then the socket will be connected
to that gateway. Otherwise, the socket is connected directly
to the specified host
and port
.
createSocket
in interface java.rmi.server.RMIClientSocketFactory
createSocket
in class java.rmi.server.RMISocketFactory
java.io.IOException
#registerGateway()
public java.net.ServerSocket createServerSocket(int port) throws java.io.IOException
createServerSocket
in interface java.rmi.server.RMIServerSocketFactory
createServerSocket
in class java.rmi.server.RMISocketFactory
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |