From 0bec35175e233138cf86e1c8661d92274e1a09df Mon Sep 17 00:00:00 2001 From: mkoch Date: Sat, 21 Sep 2002 06:59:20 +0000 Subject: 2002-09-21 Michael Koch * java/net/Socket.java (sendUrgentData): New method. (getChannel): New method. * java/net/ServerSocket.java (getChannel): New method. (isBound): New method. * java/net/DatagramSocket.java (DatagramSocket): Two new methods. (bind): New method. (getChannel): New method. (isBound): New method. (send): Added newline to to make shorter lines. * java/net/PlainDatagramSocketImpl.java (mcastGrp): Added argument. (join): Use new mcastGrp. (leave): Use new mcastGrp. (joinGroup): New method. (leaveGroup): New method. * java/net/natPlainDatagramSocketImpl.cc (mcastGrp): Added argument, no yet really implemented. (getOption): Added newline for shorter lines. * java/net/natPlainSocketImpl.cc (read, setOption, getOption): Added newline for shorter lines. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@57380 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/net/ServerSocket.java | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'libjava/java/net/ServerSocket.java') diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java index c6b187071ec..b706acca58c 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. @@ -74,6 +75,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. */ @@ -281,6 +288,39 @@ public class ServerSocket impl.close(); } + /** + * 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 -- cgit v1.2.3