Network: refactor names, add server control port, clean comments
authorEddie <dev@fun2be.me>
Sat, 6 Jun 2015 07:29:30 +0000 (08:29 +0100)
committerEddie <dev@fun2be.me>
Sat, 6 Jun 2015 07:29:30 +0000 (08:29 +0100)
Make member names specific to the Internet Protocol version 4 that they
represent. This clears the way to add IPv6 support later.

Introduce PORTS_SERVER_CONTROL since notifications to clients are now
intended to take place over the TCP stream ServerSocial and each client
maintain.

Remove FIXME comments left over from solving the 'static final'
initialisation issue.

src/uk/ac/ntu/n0521366/wsyd/libs/net/Network.java

index c899501..426f54f 100644 (file)
@@ -35,6 +35,7 @@ public class Network {
     public static final int PORTS_SERVER_CHAT = 50001;
     public static final int PORTS_SERVER_LOG = 50002;
     public static final int PORTS_MULTICAST_DISCOVERY = 50003;
+    public static final int PORTS_SERVER_CONTROL = 50004;
     public static final int PORTS_CLIENT_CONTROL_FIRST = 50010;
     public static final int PORTS_CLIENT_CHAT_FIRST = 51000;
     public static final int PORTS_EPHEMERAL = 0;
@@ -46,7 +47,7 @@ public class Network {
     /**
      * Multicast IPv4 address the applications use to discover each other.
      */
-    public static final InetAddress MULTICAST_IP;
+    public static final InetAddress MULTICAST_IPv4;
     /**
      * Unicast IPv4 address for testing network connectivity. 
      */
@@ -70,20 +71,20 @@ public class Network {
         try {
             temp = InetAddress.getByAddress(new byte[] {0,0,0,0});
         } catch (UnknownHostException ex) {
-            temp = null; //FIXME: variable IPv4_WILDCARD might already have been assigned
+            temp = null;
         }
         IPv4_WILDCARD = temp;
         
         try {
             temp  = InetAddress.getByAddress(new byte[] {(byte)239, (byte)192, (byte)3, (byte)4});
         } catch (UnknownHostException ex) {
-            temp = null; // FIXME: variable MULTICAST_IP might already have been assigned
+            temp = null;
         }
-        MULTICAST_IP = temp;
+        MULTICAST_IPv4 = temp;
         try {
             temp       = InetAddress.getByAddress(new byte[] {(byte)176, (byte)58, (byte)127, (byte)210});
         } catch (UnknownHostException ex) {
-            temp = null; // FIXME: variable PING_IP might already have been assigned
+            temp = null;
         }
         PING_IP = temp;
     }