More information: http://www.cs.berkeley.edu/~mdw/proj/seda/

seda.nbio
Class NonblockingServerSocket

java.lang.Object
  |
  +--seda.nbio.NonblockingServerSocket
All Implemented Interfaces:
Selectable

public class NonblockingServerSocket
extends java.lang.Object
implements Selectable

A NonblockingServerSocket implements a nonblocking variant of java.net.ServerSocket. (Ideally it would simply extend the latter class, but ServerSocket does not contain an appropriate public constructor which would make that feasible.)

See Also:
java.net.ServerSocket

Field Summary
(package private)  NonblockingSocketImpl impl
           
 
Fields inherited from interface seda.nbio.Selectable
ACCEPT_READY, CONNECT_READY, READ_READY, SELECT_ERROR, WRITE_READY
 
Constructor Summary
NonblockingServerSocket(int port)
          Create a nonblocking server socket listening on the given port.
NonblockingServerSocket(int port, int backlog)
          Create a nonblocking server socket listening on the given port with the given connection backlog (the default is 511).
NonblockingServerSocket(int port, int backlog, java.net.InetAddress bindAddr)
          Create a nonblocking server socket listening on the given port, with the given connection backlog, bound to the given address.
 
Method Summary
(package private) static void ()
           
 NonblockingSocket accept()
          Accept a connection on this server socket.
 void close()
          Close the socket.
 java.net.InetAddress getInetAddress()
          Return the address to which this socket is bound.
 int getLocalPort()
          Return the port to which this socket is bound.
 int getSoTimeout()
          Currently unimplemented.
 NonblockingSocket nbAccept()
          Perform a nonblocking accept() on this socket.
 void setSoTimeout(int timeout)
          Currently unimplemented.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

impl

NonblockingSocketImpl impl
Constructor Detail

NonblockingServerSocket

public NonblockingServerSocket(int port)
                        throws java.io.IOException
Create a nonblocking server socket listening on the given port.

NonblockingServerSocket

public NonblockingServerSocket(int port,
                               int backlog)
                        throws java.io.IOException
Create a nonblocking server socket listening on the given port with the given connection backlog (the default is 511).

NonblockingServerSocket

public NonblockingServerSocket(int port,
                               int backlog,
                               java.net.InetAddress bindAddr)
                        throws java.io.IOException
Create a nonblocking server socket listening on the given port, with the given connection backlog, bound to the given address. This is useful if you wish to bind the socket to an address other than INADDR_ANY.
Method Detail

static void ()

accept

public NonblockingSocket accept()
                         throws java.io.IOException
Accept a connection on this server socket. This is a blocking operation.
Returns:
A NonblockingSocket corresponding to the new connection.

nbAccept

public NonblockingSocket nbAccept()
                           throws java.io.IOException
Perform a nonblocking accept() on this socket. Returns null if no connection was established. Selecting this socket for ACCEPT_READY will allow you to determine if nbAccept() will return a new connection.
See Also:
SelectSet

getInetAddress

public java.net.InetAddress getInetAddress()
Return the address to which this socket is bound.

getLocalPort

public int getLocalPort()
Return the port to which this socket is bound.

setSoTimeout

public void setSoTimeout(int timeout)
                  throws java.net.SocketException
Currently unimplemented.

getSoTimeout

public int getSoTimeout()
                 throws java.net.SocketException
Currently unimplemented.

close

public void close()
           throws java.io.IOException
Close the socket.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

More information: http://www.cs.berkeley.edu/~mdw/proj/seda/