org.sapia.ubik.net.mplex
Class SocketConnectorImpl

java.lang.Object
  extended by org.sapia.ubik.net.mplex.SocketConnectorImpl
All Implemented Interfaces:
MultiplexSocketConnector

public class SocketConnectorImpl
extends java.lang.Object
implements MultiplexSocketConnector

Class documentation

Author:
Jean-Cedric Desrochers
Copyright:
Copyright © 2002-2004 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Constructor Summary
SocketConnectorImpl(MultiplexServerSocket aServerSocket, StreamSelector aSelector, SocketQueue aQueue)
          Creates a new SocketConnectorImpl instance.
 
Method Summary
 java.net.Socket accept()
          Listens for a connection to be made to this socket and accepts it.
 void close()
          Closes this multiplex socket handler.
 java.net.InetAddress getInetAddress()
          Returns the local address of this server socket.
 int getLocalPort()
          Returns the port on which this socket is listening.
 java.net.SocketAddress getLocalSocketAddress()
          Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.
 SocketQueue getQueue()
          Returns the socket queue of this handler.
 int getReceiveBufferSize()
          Gets the value of the SO_RCVBUF option for this socket interceptor that is the proposed buffer size that will be used for Sockets accepted from this socket interceptor.
 boolean getReuseAddress()
          Tests if SO_REUSEADDR is enabled.
 StreamSelector getSelector()
          Returns the selector associated to this handler.
 int getSoTimeout()
          (i.e., timeout of infinity).
 boolean isBound()
          Returns the binding state of the socket.
 boolean isClosed()
          Returns the closed state of the socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketConnectorImpl

public SocketConnectorImpl(MultiplexServerSocket aServerSocket,
                           StreamSelector aSelector,
                           SocketQueue aQueue)
Creates a new SocketConnectorImpl instance.

Method Detail

getSelector

public StreamSelector getSelector()
Returns the selector associated to this handler.

Returns:
The selector associated to this handler.

getQueue

public SocketQueue getQueue()
Returns the socket queue of this handler.

Returns:
The socket queue of this handler.

getLocalPort

public int getLocalPort()
Returns the port on which this socket is listening.

Specified by:
getLocalPort in interface MultiplexSocketConnector
Returns:
The port number to which this socket is listening or -1 if the socket is not bound yet.

getInetAddress

public java.net.InetAddress getInetAddress()
Returns the local address of this server socket.

Specified by:
getInetAddress in interface MultiplexSocketConnector
Returns:
The address to which this socket is bound, or null if the socket is unbound.

getLocalSocketAddress

public java.net.SocketAddress getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.

Specified by:
getLocalSocketAddress in interface MultiplexSocketConnector
Returns:
A SocketAddress representing the local endpoint of this socket, or null if it is not bound yet.

getReceiveBufferSize

public int getReceiveBufferSize()
                         throws java.net.SocketException
Gets the value of the SO_RCVBUF option for this socket interceptor that is the proposed buffer size that will be used for Sockets accepted from this socket interceptor.

Specified by:
getReceiveBufferSize in interface MultiplexSocketConnector
Returns:
the value of the SO_RCVBUF option for this Socket.
Throws:
java.net.SocketException - if there is an error in the underlying protocol.

getReuseAddress

public boolean getReuseAddress()
                        throws java.net.SocketException
Tests if SO_REUSEADDR is enabled.

Specified by:
getReuseAddress in interface MultiplexSocketConnector
Returns:
A boolean indicating whether or not SO_REUSEADDR is enabled.
Throws:
java.net.SocketException - if there is an error in the underlying protocol.

getSoTimeout

public int getSoTimeout()
                 throws java.io.IOException
(i.e., timeout of infinity).

Specified by:
getSoTimeout in interface MultiplexSocketConnector
Returns:
the SO_TIMEOUT value
Throws:
java.io.IOException - if an I/O error occurs

isBound

public boolean isBound()
Returns the binding state of the socket.

Specified by:
isBound in interface MultiplexSocketConnector
Returns:
True if the socket succesfuly bound to an address.

isClosed

public boolean isClosed()
Returns the closed state of the socket.

Specified by:
isClosed in interface MultiplexSocketConnector
Returns:
True if the socket has been closed.

accept

public java.net.Socket accept()
                       throws java.io.IOException
Listens for a connection to be made to this socket and accepts it. The method blocks until a connection is made.

Specified by:
accept in interface MultiplexSocketConnector
Returns:
The new Socket
Throws:
java.io.IOException - If an I/O error occurs when waiting for a connection.

close

public void close()
           throws java.io.IOException
Closes this multiplex socket handler.

Specified by:
close in interface MultiplexSocketConnector
Throws:
java.io.IOException - if an I/O error occurs when closing the socket.


Copyright © 2010 Sapia OSS. All Rights Reserved.