From 5cee352894a9cfe4267a8f753008d708b88f5ed9 Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Wed, 6 Dec 2017 16:26:14 +0100 Subject: [PATCH] added handling to listen under IP addresses other than 127.0.0.1 --- .../rmi/RMIMandelbrotCalculationsServer.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer.java b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer.java index b836953..6a92d08 100644 --- a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer.java +++ b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer.java @@ -1,9 +1,28 @@ package verteiltesysteme.mandelbrot.rmi; +import java.io.IOException; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; +import java.rmi.server.RMISocketFactory; import java.rmi.server.UnicastRemoteObject; +/* +class LoopbackSocketFactory extends RMISocketFactory { + public ServerSocket createServerSocket(int port) throws IOException { + return new ServerSocket(port, 5, InetAddress.getByName("127.0.0.1")); + } + + public Socket createSocket(String host, int port) throws IOException { + // just call the default client socket factory + return RMISocketFactory.getDefaultSocketFactory() + .createSocket(host, port); + } +} +*/ + class Complex { double r; double i; @@ -45,6 +64,8 @@ public class RMIMandelbrotCalculationsServer implements RMIMandelbrotCalculation public static void main(String args[]) { try { + //RMISocketFactory.setSocketFactory(new LoopbackSocketFactory()); + RMIMandelbrotCalculationsServer obj = new RMIMandelbrotCalculationsServer(); RMIMandelbrotCalculationsInterface stub = (RMIMandelbrotCalculationsInterface) UnicastRemoteObject.exportObject(obj, 0); @@ -127,4 +148,4 @@ public class RMIMandelbrotCalculationsServer implements RMIMandelbrotCalculation this.LRy = LRy; } -} \ No newline at end of file +}