public interface MultiplexSocketConnector
accept() method.
A connector instance can be created using the
MultiplexServerSocket.createSocketConnector(StreamSelector)
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.
MultiplexServerSocket,
StreamSelector| Modifier and Type | Method and Description |
|---|---|
Socket |
accept()
Listens for a connection to be made to this socket and accepts
it.
|
void |
close()
Closes this multiplex socket handler.
|
InetAddress |
getInetAddress()
Returns the local address of this server socket.
|
int |
getLocalPort()
Returns the port on which this socket is listening.
|
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.
|
int getLocalPort()
InetAddress getInetAddress()
null if the socket is unbound.SocketAddress getLocalSocketAddress()
null if it is not bound yet.SocketAddress representing the local endpoint of this
socket, or null if it is not bound yet.int getReceiveBufferSize()
throws SocketException
SocketException - if there is an error in the underlying protocol.boolean getReuseAddress()
throws SocketException
boolean indicating whether or not SO_REUSEADDR is enabled.SocketException - if there is an error in the underlying protocol.int getSoTimeout()
throws IOException
IOException - if an I/O error occursboolean isBound()
boolean isClosed()
Socket accept() throws IOException
IOException - If an I/O error occurs when waiting for a connection.void close()
throws IOException
IOException - if an I/O error occurs when closing the socket.Copyright © 2012 Sapia OSS. All Rights Reserved.