From 986a66f3b2e73b77d0be3a85a249e97108ffd8c7 Mon Sep 17 00:00:00 2001 From: "lubomir.marinov" Date: Mon, 15 Feb 2010 18:01:24 +0000 Subject: [PATCH] Extends MultiplexingDatagramSocket from SafeCloseDatagramSocket. --- .../socket/MultiplexingDatagramSocket.java | 2 +- .../ice4j/socket/SafeCloseDatagramSocket.java | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/org/ice4j/socket/MultiplexingDatagramSocket.java b/src/org/ice4j/socket/MultiplexingDatagramSocket.java index 131d0ca..c515cd5 100644 --- a/src/org/ice4j/socket/MultiplexingDatagramSocket.java +++ b/src/org/ice4j/socket/MultiplexingDatagramSocket.java @@ -21,7 +21,7 @@ import java.util.*; * @author Lubomir Marinov */ public class MultiplexingDatagramSocket - extends DatagramSocket + extends SafeCloseDatagramSocket { /** diff --git a/src/org/ice4j/socket/SafeCloseDatagramSocket.java b/src/org/ice4j/socket/SafeCloseDatagramSocket.java index e3b927e..520c62c 100644 --- a/src/org/ice4j/socket/SafeCloseDatagramSocket.java +++ b/src/org/ice4j/socket/SafeCloseDatagramSocket.java @@ -35,6 +35,21 @@ public class SafeCloseDatagramSocket */ private final Object inReceiveSyncRoot = new Object(); + /** + * Initializes a new SafeCloseDatagramSocket instance and binds it + * to any available port on the local host machine. The socket will be + * bound to the wildcard address, an IP address chosen by the kernel. + * + * @throws SocketException if the socket could not be opened, or the socket + * could not bind to the specified local port + * @see DatagramSocket#DatagramSocket() + */ + public SafeCloseDatagramSocket() + throws SocketException + { + super(); + } + /** * Creates a datagram socket, bound to the specified local socket address. *

@@ -52,6 +67,40 @@ public class SafeCloseDatagramSocket super(bindaddr); } + /** + * Initializes a new SafeCloseDatagramSocket instance and binds it + * to the specified port on the local host machine. The socket will be + * bound to the wildcard address, an IP address chosen by the kernel. + * + * @param port the port to bind the new socket to + * @throws SocketException if the socket could not be opened, or the socket + * could not bind to the specified local port + * @see DatagramSocket#DatagramSocket(int) + */ + public SafeCloseDatagramSocket(int port) + throws SocketException + { + super(port); + } + + /** + * Initializes a new SafeCloseDatagramSocket instance bound to the + * specified local address. The local port must be between 0 and 65535 + * inclusive. If the IP address is 0.0.0.0, the socket will be bound to the + * wildcard address, an IP address chosen by the kernel. + * + * @param port the local port to bind the new socket to + * @param laddr the local address to bind the new socket to + * @throws SocketException if the socket could not be opened, or the socket + * could not bind to the specified local port + * @see DatagramSocket#DatagramSocket(int, InetAddress) + */ + public SafeCloseDatagramSocket(int port, InetAddress laddr) + throws SocketException + { + super(port, laddr); + } + /** * Closes this datagram socket. *