aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-01-30 20:32:20 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-01-30 20:32:20 +0000
commit18afaec076602d242161cbf907d0735f99756b33 (patch)
tree781eaec7ca6c22cae1712394300a798c9c46210d
parent787ea33338b67f6d2ee7cfb400efc7bc4affe74c (diff)
downloadNetworkCoursework-18afaec076602d242161cbf907d0735f99756b33.tar.gz
NetworkCoursework-18afaec076602d242161cbf907d0735f99756b33.zip
Fixed files using uncrustify
-rwxr-xr-xrmi/RMIClient.java5
-rwxr-xr-xrmi/RMIServer.java9
-rwxr-xr-xudp/UDPClient.java22
-rwxr-xr-xudp/UDPServer.java16
4 files changed, 19 insertions, 33 deletions
diff --git a/rmi/RMIClient.java b/rmi/RMIClient.java
index 4de0e48..60e25c8 100755
--- a/rmi/RMIClient.java
+++ b/rmi/RMIClient.java
@@ -10,13 +10,11 @@ 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){
+ if(args.length < 2) {
System.out.println("Needs 2 arguments: ServerHostName/IPAddress, TotalMessageCount");
System.exit(-1);
}
@@ -29,6 +27,5 @@ public class RMIClient {
// 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
index 8193a4c..2ce8d56 100755
--- a/rmi/RMIServer.java
+++ b/rmi/RMIServer.java
@@ -14,7 +14,6 @@ import java.util.Arrays;
import common.*;
public class RMIServer extends UnicastRemoteObject implements RMIServerI {
-
private int totalMessages = -1;
private int[] receivedMessages;
@@ -22,33 +21,27 @@ public class RMIServer extends UnicastRemoteObject implements RMIServerI {
}
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) {
+ 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)
diff --git a/udp/UDPClient.java b/udp/UDPClient.java
index 848e996..079b451 100755
--- a/udp/UDPClient.java
+++ b/udp/UDPClient.java
@@ -13,24 +13,23 @@ import java.net.UnknownHostException;
import common.MessageInfo;
public class UDPClient {
-
private DatagramSocket sendSoc;
public static void main(String[] args) {
- InetAddress serverAddr = null;
- int recvPort;
- int countTo;
- String message;
+ InetAddress serverAddr = null;
+ int recvPort;
+ int countTo;
+ String message;
// Get the parameters
- if (args.length < 3) {
+ if(args.length < 3) {
System.err.println("Arguments required: server name/IP, recv port, message count");
System.exit(-1);
}
try {
serverAddr = InetAddress.getByName(args[0]);
- } catch (UnknownHostException e) {
+ } catch(UnknownHostException e) {
System.out.println("Bad server address in UDPClient, " + args[0] + " caused an unknown host exception " + e);
System.exit(-1);
}
@@ -46,15 +45,16 @@ public class UDPClient {
}
private void testLoop(InetAddress serverAddr, int recvPort, int countTo) {
- int tries = 0;
+ int tries = 0;
// TO-DO: Send the messages to the server
}
private void send(String payload, InetAddress destAddr, int destPort) {
- int payloadSize;
- byte[] pktData;
- DatagramPacket pkt;
+ int payloadSize;
+
+ byte[] pktData;
+ DatagramPacket pkt;
// TO-DO: build the datagram packet and send it to the server
}
diff --git a/udp/UDPServer.java b/udp/UDPServer.java
index 8659d25..f7f5b1e 100755
--- a/udp/UDPServer.java
+++ b/udp/UDPServer.java
@@ -13,24 +13,22 @@ import java.util.Arrays;
import common.MessageInfo;
public class UDPServer {
-
private DatagramSocket recvSoc;
private int totalMessages = -1;
private int[] receivedMessages;
private boolean close;
private void run() {
- int pacSize;
- byte[] pacData;
- DatagramPacket pac;
+ int pacSize;
+
+ byte[] pacData;
+ DatagramPacket pac;
// TO-DO: Receive the messages and process them by calling processMessage(...).
// Use a timeout (e.g. 30 secs) to ensure the program doesn't block forever
-
}
public void processMessage(String data) {
-
MessageInfo msg = null;
// TO-DO: Use the data to construct a new MessageInfo object
@@ -41,7 +39,6 @@ public class UDPServer {
// TO-DO: If this is the last expected message, then identify
// any missing messages
-
}
@@ -53,10 +50,10 @@ public class UDPServer {
}
public static void main(String args[]) {
- int recvPort;
+ int recvPort;
// Get the parameters from command line
- if (args.length < 1) {
+ if(args.length < 1) {
System.err.println("Arguments required: recv port");
System.exit(-1);
}
@@ -64,5 +61,4 @@ public class UDPServer {
// TO-DO: Construct Server object and start it by calling run().
}
-
}