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

nbio.NonblockingSocket Class Reference

Inherits Socket, and 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

void loadNativeLibrary ()
 [static initializer]

Package Attributes

NonblockingSocketImpl impl
boolean is_connected

Static Package Attributes

boolean nativeLibraryLoaded = false
Object nativeLibraryLoadLock = new Object()


Constructor & Destructor Documentation

nbio.NonblockingSocket.NonblockingSocket  )  throws IOException [package]
 

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.

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.

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.

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

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

synchronized void nbio.NonblockingSocket.close  )  throws IOException
 

Closes the socket.

boolean 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 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 nbio.NonblockingSocket.getInetAddress  ) 
 

Return the remote address to which this socket is bound.

InputStream 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 nbio.NonblockingSocket.getLocalAddress  ) 
 

Return the local address to which this socket is bound.

int nbio.NonblockingSocket.getLocalPort  ) 
 

Return the local port to which this socket is bound.

OutputStream 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 nbio.NonblockingSocket.getPort  ) 
 

Return the remote port to which this socket is bound.

int nbio.NonblockingSocket.getSoLinger  )  throws SocketException
 

Currently unimplemented.

synchronized int nbio.NonblockingSocket.getSoTimeout  )  throws SocketException
 

Currently unimplemented.

boolean nbio.NonblockingSocket.getTcpNoDelay  )  throws SocketException
 

Currently unimplemented.

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

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

Currently unimplemented.

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

Currently unimplemented.

void nbio.NonblockingSocket.setTcpNoDelay boolean  on  )  throws SocketException
 

Currently unimplemented.

String nbio.NonblockingSocket.toString  ) 
 


Member Data Documentation

NonblockingSocketImpl nbio.NonblockingSocket.impl [package]
 

boolean nbio.NonblockingSocket.is_connected [package]
 

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

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


The documentation for this class was generated from the following file:
Generated on Fri Jul 18 21:37:51 2003 for libnbio2-java by doxygen 1.3.2