Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members

seda.nbio.NonblockingSocket Class Reference

Inherits Socket, and seda.nbio.Selectable.

List of all members.


Detailed Description

A NonblockingSocket is a socket which exports nonblocking input/output streams.

It is otherwise idential to a standard socket.

Socket connection can be either blocking or nonblocking. Use of the standard constructors causes the current thread to block until the connection is established. Otherwise, there are 3 ways to check if the connection has been established: (1) Call finishConnection, (2) Call connectDone, or (3) Create a SelectSet and select on the event Selectable.CONNECT_READY, then call connectDone.

See also:
SelectSet


Public Member Functions

 NonblockingSocket (String host, int port) throws UnknownHostException, IOException
 Create a NonblockingSocket connection to the given host and port number.
 NonblockingSocket (String host, int port, boolean block) throws UnknownHostException, IOException
 Create a NonblockingSocket connection to the given host and port number.
 NonblockingSocket (InetAddress address, int port) throws UnknownHostException, IOException
 Create a NonblockingSocket connection to the given host and port number.
 NonblockingSocket (InetAddress address, int port, boolean block) throws IOException
 Create a NonblockingSocket connection to the given host and port number.
boolean finishConnect (int timeout) throws SocketException
 Block until the connection on this socket has been established.
boolean connectDone () throws SocketException
 Indicate whether the connection on this socket has been established.
InetAddress getInetAddress ()
 Return the remote address to which this socket is bound.
InetAddress getLocalAddress ()
 Return the local address to which this socket is bound.
int getPort ()
 Return the remote port to which this socket is bound.
int getLocalPort ()
 Return the local port to which this socket is bound.
InputStream getInputStream () throws IOException
 Return an InputStream from which data on this socket can be read.
OutputStream getOutputStream () throws IOException
 Return an OutputStream to which data on this socket can be written.
void setTcpNoDelay (boolean on) throws SocketException
 Currently unimplemented.
boolean getTcpNoDelay () throws SocketException
 Currently unimplemented.
void setSoLinger (boolean on, int val) throws SocketException
 Currently unimplemented.
int getSoLinger () throws SocketException
 Currently unimplemented.
synchronized void setSoTimeout (int timeout) throws SocketException
 Currently unimplemented.
synchronized int getSoTimeout () throws SocketException
 Currently unimplemented.
synchronized void close () throws IOException
 Closes the socket.
String toString ()

Package Functions

 NonblockingSocket () throws IOException

Static Package Functions

static void loadNativeLibrary ()
 [static initializer]

Package Attributes

NonblockingSocketImpl impl
boolean is_connected

Static Package Attributes

static boolean nativeLibraryLoaded = false
static Object nativeLibraryLoadLock = new Object()


Constructor & Destructor Documentation

seda.nbio.NonblockingSocket.NonblockingSocket  )  throws IOException [package]
 

seda.nbio.NonblockingSocket.NonblockingSocket String  host,
int  port
throws UnknownHostException, IOException
 

Create a NonblockingSocket connection to the given host and port number.

This will block until the connection is established.

seda.nbio.NonblockingSocket.NonblockingSocket String  host,
int  port,
boolean  block
throws UnknownHostException, IOException
 

Create a NonblockingSocket connection to the given host and port number.

If 'block' is true, block until the connection is done.

seda.nbio.NonblockingSocket.NonblockingSocket InetAddress  address,
int  port
throws UnknownHostException, IOException
 

Create a NonblockingSocket connection to the given host and port number.

This will block until the connection is established.

seda.nbio.NonblockingSocket.NonblockingSocket InetAddress  address,
int  port,
boolean  block
throws IOException
 

Create a NonblockingSocket connection to the given host and port number.

If 'block' is true, block until the connection is done.


Member Function Documentation

seda.nbio.NonblockingSocket.[static initializer]  )  [static, package]
 

synchronized void seda.nbio.NonblockingSocket.close  )  throws IOException
 

Closes the socket.

boolean seda.nbio.NonblockingSocket.connectDone  )  throws SocketException
 

Indicate whether the connection on this socket has been established.

Throws an exception if an error occurred trying to connect.

boolean seda.nbio.NonblockingSocket.finishConnect int  timeout  )  throws SocketException
 

Block until the connection on this socket has been established.

'timeout' specifies the maximum number of milliseconds to block. A timeout of zero indicates no blocking (in which case this call is equivalent to connectDone). A timeout of -1 causes this call to block indefinitely until the connection is established.

Returns:
true is the connection was established, false if still pending.

InetAddress seda.nbio.NonblockingSocket.getInetAddress  ) 
 

Return the remote address to which this socket is bound.

InputStream seda.nbio.NonblockingSocket.getInputStream  )  throws IOException
 

Return an InputStream from which data on this socket can be read.

The returned InputStream is actually a NonblockingInputStream and provides nonblocking semantics.

InetAddress seda.nbio.NonblockingSocket.getLocalAddress  ) 
 

Return the local address to which this socket is bound.

int seda.nbio.NonblockingSocket.getLocalPort  ) 
 

Return the local port to which this socket is bound.

OutputStream seda.nbio.NonblockingSocket.getOutputStream  )  throws IOException
 

Return an OutputStream to which data on this socket can be written.

The returned OutputStream is actually a NonblockingOutputStream and provides nonblocking semantics.

int seda.nbio.NonblockingSocket.getPort  ) 
 

Return the remote port to which this socket is bound.

int seda.nbio.NonblockingSocket.getSoLinger  )  throws SocketException
 

Currently unimplemented.

synchronized int seda.nbio.NonblockingSocket.getSoTimeout  )  throws SocketException
 

Currently unimplemented.

boolean seda.nbio.NonblockingSocket.getTcpNoDelay  )  throws SocketException
 

Currently unimplemented.

static void seda.nbio.NonblockingSocket.loadNativeLibrary  )  [static, package]
 

void seda.nbio.NonblockingSocket.setSoLinger boolean  on,
int  val
throws SocketException
 

Currently unimplemented.

synchronized void seda.nbio.NonblockingSocket.setSoTimeout int  timeout  )  throws SocketException
 

Currently unimplemented.

void seda.nbio.NonblockingSocket.setTcpNoDelay boolean  on  )  throws SocketException
 

Currently unimplemented.

String seda.nbio.NonblockingSocket.toString  ) 
 


Member Data Documentation

NonblockingSocketImpl seda.nbio.NonblockingSocket.impl [package]
 

boolean seda.nbio.NonblockingSocket.is_connected [package]
 

boolean seda.nbio.NonblockingSocket.nativeLibraryLoaded = false [static, package]
 

Object seda.nbio.NonblockingSocket.nativeLibraryLoadLock = new Object() [static, package]
 


The documentation for this class was generated from the following file:
Generated on Sat Apr 2 04:10:22 2005 for libnbio2-java by  doxygen 1.4.2