aboutsummaryrefslogtreecommitdiffstats
path: root/rmi
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2017-01-29 17:14:05 +0000
committerymherklotz <ymherklotz@gmail.com>2017-01-29 17:14:05 +0000
commit787ea33338b67f6d2ee7cfb400efc7bc4affe74c (patch)
tree6d7c5c421521f70641544aa5bddf0b2366c39490 /rmi
parent28e7f14035c8703939bfecc4b2c9f389671e4752 (diff)
downloadNetworkCoursework-787ea33338b67f6d2ee7cfb400efc7bc4affe74c.tar.gz
NetworkCoursework-787ea33338b67f6d2ee7cfb400efc7bc4affe74c.zip
Adding files to repo
Diffstat (limited to 'rmi')
-rwxr-xr-xrmi/RMIClient.java34
-rwxr-xr-xrmi/RMIServer.java61
-rwxr-xr-xrmi/RMIServerI.java13
3 files changed, 108 insertions, 0 deletions
diff --git a/rmi/RMIClient.java b/rmi/RMIClient.java
new file mode 100755
index 0000000..4de0e48
--- /dev/null
+++ b/rmi/RMIClient.java
@@ -0,0 +1,34 @@
+/*
+ * Created on 01-Mar-2016
+ */
+package rmi;
+
+import java.rmi.Naming;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+
+import common.MessageInfo;
+
+public class RMIClient {
+
+ public static void main(String[] args) {
+
+ RMIServerI iRMIServer = null;
+
+ // Check arguments for Server host and number of messages
+ if (args.length < 2){
+ System.out.println("Needs 2 arguments: ServerHostName/IPAddress, TotalMessageCount");
+ System.exit(-1);
+ }
+
+ String urlServer = new String("rmi://" + args[0] + "/RMIServer");
+ int numMessages = Integer.parseInt(args[1]);
+
+ // TO-DO: Initialise Security Manager
+
+ // TO-DO: Bind to RMIServer
+
+ // TO-DO: Attempt to send messages the specified number of times
+
+ }
+}
diff --git a/rmi/RMIServer.java b/rmi/RMIServer.java
new file mode 100755
index 0000000..8193a4c
--- /dev/null
+++ b/rmi/RMIServer.java
@@ -0,0 +1,61 @@
+/*
+ * Created on 01-Mar-2016
+ */
+package rmi;
+
+import java.net.MalformedURLException;
+import java.rmi.Naming;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.RemoteException;
+import java.rmi.RMISecurityManager;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Arrays;
+
+import common.*;
+
+public class RMIServer extends UnicastRemoteObject implements RMIServerI {
+
+ private int totalMessages = -1;
+ private int[] receivedMessages;
+
+ public RMIServer() throws RemoteException {
+ }
+
+ public void receiveMessage(MessageInfo msg) throws RemoteException {
+
+ // TO-DO: On receipt of first message, initialise the receive buffer
+
+ // TO-DO: Log receipt of the message
+
+ // TO-DO: If this is the last expected message, then identify
+ // any missing messages
+
+ }
+
+
+ public static void main(String[] args) {
+
+ RMIServer rmis = null;
+
+ if(System.getSecurityManager() == null) {
+ System.setSecurityManager(new RMISecurityManager());
+ }
+
+ // TO-DO: Instantiate the server class
+
+ // TO-DO: Bind to RMI registry
+
+ }
+
+ protected static void rebindServer(String serverURL, RMIServer server) {
+
+ // TO-DO:
+ // Start / find the registry (hint use LocateRegistry.createRegistry(...)
+ // If we *know* the registry is running we could skip this (eg run rmiregistry in the start script)
+
+ // TO-DO:
+ // Now rebind the server to the registry (rebind replaces any existing servers bound to the serverURL)
+ // Note - Registry.rebind (as returned by createRegistry / getRegistry) does something similar but
+ // expects different things from the URL field.
+ }
+}
diff --git a/rmi/RMIServerI.java b/rmi/RMIServerI.java
new file mode 100755
index 0000000..b211db3
--- /dev/null
+++ b/rmi/RMIServerI.java
@@ -0,0 +1,13 @@
+/*
+ * Created on 01-Mar-2016
+ */
+package rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import common.*;
+
+public interface RMIServerI extends Remote {
+ public void receiveMessage(MessageInfo msg) throws RemoteException;
+}