org.sapia.ubik.net.mplex
Interface MultiplexSocketConnector

All Known Implementing Classes:
SocketConnectorImpl

public interface MultiplexSocketConnector

The MultiplexSocketConnector class is the access point to get client socket connections in the multiplex logic. Its functionality is similar to the traditional server socket, which gives you the next socket connection upon calling the accept() method.

A connector instance can be created using the createSocketConnector() method of the class MultiplexServerSocket, providing a StreamSelector object. Upon this call, the server socket will create a new connector instance that will be associated to the server socket. The selector passed in will be used to determine if this connector will handle or not a new client socket connection. After you need to call the accept() to get the next client socket connection (blocking call). Finally when you are done with this socket connector a call to the close() method is required to release all the resource used by this socket connector. Note that closing the socket connector will not close the underlying server socket.

All the accessor methods that returns a state delegates the call to the underlying server socket. For example a call to get the port number on which is connector is bound to, using the getLocalPort() method, will pass the request to the server socket that is associated with this socket connector.

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
See Also:
MultiplexServerSocket, StreamSelector

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.
 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.
 int getSoTimeout()
          Retrieve setting for SO_TIMEOUT.
 boolean isBound()
          Returns the binding state of the socket.
 boolean isClosed()
          Returns the closed state of the socket.
 

Method Detail

getLocalPort

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

Returns:
The port number to which this socket is listening or -1 if the socket is not bound yet.

getInetAddress

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

Returns:
The address to which this socket is bound, or null if the socket is unbound.

getLocalSocketAddress

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

Returns:
A SocketAddress representing the local endpoint of this socket, or null if it is not bound yet.

getReceiveBufferSize

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.

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

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

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

int getSoTimeout()
                 throws java.io.IOException
Retrieve setting for SO_TIMEOUT. Zero returns implies that the option is disabled (i.e., timeout of infinity).

Returns:
the SO_TIMEOUT value
Throws:
java.io.IOException - if an I/O error occurs

isBound

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

Returns:
True if the socket succesfuly bound to an address.

isClosed

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

Returns:
True if the socket has been closed.

accept

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.

Returns:
The new Socket
Throws:
java.io.IOException - If an I/O error occurs when waiting for a connection.

close

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

Throws:
java.io.IOException - if an I/O error occurs when closing the socket.


Copyright © 2010 Sapia OSS. All Rights Reserved.