Index: src/main/java/com/sun/grizzly/TCPSelectorHandler.java =================================================================== --- src/main/java/com/sun/grizzly/TCPSelectorHandler.java (revision 4605) +++ src/main/java/com/sun/grizzly/TCPSelectorHandler.java (working copy) @@ -52,6 +52,7 @@ import java.io.IOException; import java.net.BindException; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketAddress; @@ -1123,6 +1124,28 @@ return -1; } + /** + * Get {@link SocketAddress} to which SelectionHandler is bound. + * A typical usage will be: + *
+     *    InetSocketAddress socketAddress = selectionHandler.getInetSocketAddress();
+     *    if( socketAddress.getAddress().isAnyLocalAddress() ) {
+     *       System.out.println("bound to all interfaces");
+     *    }else{
+     *        System.out.println("bound to interface: " + socketAddress.getAddress() );
+     *    }
+     * 
+ * + * @return socketAddress or null if SelectionHandler is not bound yet. + * @since 1.9.9 + */ + public InetSocketAddress getInetSocketAddress() { + if(serverSocket == null) + return null; + + return (InetSocketAddress)serverSocket.getLocalSocketAddress(); + } + public int getPort() { return port; }