import java.net.UnknownHostException;
import java.io.IOException;
import java.text.MessageFormat;
-import uk.ac.ntu.n0521366.wsyd.libs.net.Network;
-
/**
* Network socket properties.
* @author Eddie Berrisford-Lynch <dev@fun2be.me>
*/
public class WSYD_SocketAddress implements java.io.Serializable {
+
+ /**
+ * true if this (UDP) socket should be part of a multicast group.
+ */
Boolean _multicast;
+
+ /**
+ * true if the protocol:address:port combination is known to be responding.
+ */
Boolean _isReachable;
+
+ /**
+ * The IP Protocol to use.
+ */
Protocol _protocol;
+
+ /**
+ * The underlying socket address object.
+ */
InetSocketAddress _socketAddress;
- public static enum Protocol {TCP, UDP}
+ /**
+ * Use descriptive mnemonic for selection of the IP Protocol.
+ */
+ public static enum Protocol {
+ /**
+ * IP TCP protocol.
+ */
+ TCP,
+ /**
+ * IP UDP protocol. (Multicast uses UDP)
+ */
+ UDP
+ }
+ /**
+ * Convert an IPv4 String to a 4 byte (32-bit) representation.
+ *
+ * @param ipv4 dotted-decimal string representation
+ * @return literal value used by other network socket class methods
+ * @throws IllegalArgumentException
+ */
public static byte[] stringIPv4ToBytes4(String ipv4) throws IllegalArgumentException {
byte[] result = new byte[4];
if (ipv4 == null)
}
/**
- * Construct a viable Socket.
+ * Construction viable socket from a SocketAddress.
+ * @param socketAddress the IP:port pair
+ * @param protocol
+ */
+ public WSYD_SocketAddress(InetSocketAddress socketAddress, Protocol protocol) {
+ this();
+ _socketAddress = socketAddress;
+ _protocol = protocol;
+ }
+
+ /**
+ * Construct viable Socket from component parts.
*
* @param address host IP address
* @param port number