aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/net/ServerSocket.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/net/ServerSocket.java')
-rw-r--r--libjava/java/net/ServerSocket.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java
index c6b1870..b706acc 100644
--- a/libjava/java/net/ServerSocket.java
+++ b/libjava/java/net/ServerSocket.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.net;
import java.io.IOException;
+import java.nio.channels.ServerSocketChannel;
/* Written using on-line Java Platform 1.2 API Specification.
* Status: I believe all methods are implemented.
@@ -75,6 +76,12 @@ public class ServerSocket
private SocketImpl impl;
/**
+ * ServerSocketChannel of this ServerSocket. This channel only exists
+ * when the socket is created by ServerSocketChannel.open().
+ */
+ private ServerSocketChannel ch;
+
+ /**
* Private constructor that simply sets the implementation.
*/
private ServerSocket()
@@ -282,6 +289,39 @@ public class ServerSocket
}
/**
+ * Returns the unique ServerSocketChannel object
+ * associated with this socket, if any.
+ *
+ * The socket only has a ServerSocketChannel if its created
+ * by ServerSocketChannel.open.
+ *
+ * @since 1.4
+ */
+ public ServerSocketChannel getChannel()
+ {
+ return ch;
+ }
+
+ /**
+ * Returns true then the socket is bound, otherwise false
+ *
+ * @since 1.4
+ */
+ public boolean isBound()
+ {
+ try
+ {
+ Object bindaddr = impl.getOption (SocketOptions.SO_BINDADDR);
+ }
+ catch (SocketException e)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
* Sets the value of SO_TIMEOUT. A value of 0 implies that SO_TIMEOUT is
* disabled (ie, operations never time out). This is the number of
* milliseconds a socket operation can block before an