public class MuxServerSocketChannelFactory extends Object
ServerSocketChannel
s which
are capable of sharing their listening endpoints with multiple others like
them.Modifier and Type | Field and Description |
---|---|
private static Logger |
logger
The
Logger used by the MuxServerSocketChannelFactory
class (and its instances) to print debug information. |
private static Method |
OPEN_AND_BIND_METHOD
The reflection of the
openAndBind method of the
MuxServerSocketChannel class. |
static int |
SOCKET_CHANNEL_READ_TIMEOUT
The maximum number of milliseconds to wait for an accepted
SocketChannel to provide incoming/readable data before it is
considered abandoned by the client. |
static String |
SOCKET_REUSE_ADDRESS_PROPERTY_NAME
The name of the
boolean property of the socket property
of the ServerSocketChannel returned by
openAndBindMuxServerSocketChannel(Map, SocketAddress, int,
DatagramPacketFilter) which specifies the value of the
SO_REUSEADDR socket option. |
Constructor and Description |
---|
MuxServerSocketChannelFactory() |
Modifier and Type | Method and Description |
---|---|
static void |
closeNoExceptions(Channel channel)
Closes a
Channel and swallows any IOException . |
static ServerSocketChannel |
openAndBindMuxServerSocketChannel(Map<String,Object> properties,
SocketAddress endpoint,
int backlog,
DatagramPacketFilter filter)
Opens and binds a new
MuxServerSocketChannel instance if
supported by the runtime. |
static ServerSocketChannel |
openAndBindServerSocketChannel(Map<String,Object> properties,
SocketAddress endpoint,
int backlog)
Opens and binds a new
ServerSocketChannel instance. |
private static final Logger logger
Logger
used by the MuxServerSocketChannelFactory
class (and its instances) to print debug information.private static final Method OPEN_AND_BIND_METHOD
openAndBind
method of the
MuxServerSocketChannel
class.public static final int SOCKET_CHANNEL_READ_TIMEOUT
SocketChannel
to provide incoming/readable data before it is
considered abandoned by the client.public static final String SOCKET_REUSE_ADDRESS_PROPERTY_NAME
boolean
property of the socket
property
of the ServerSocketChannel
returned by
openAndBindMuxServerSocketChannel(Map, SocketAddress, int,
DatagramPacketFilter)
which specifies the value of the
SO_REUSEADDR
socket option.public static void closeNoExceptions(Channel channel)
Channel
and swallows any IOException
.channel
- the Channel
to closepublic static ServerSocketChannel openAndBindMuxServerSocketChannel(Map<String,Object> properties, SocketAddress endpoint, int backlog, DatagramPacketFilter filter) throws IOException
MuxServerSocketChannel
instance if
supported by the runtime. If there are other (existing)
MuxServerSocketChannel
open and bound on the specified listening
endpoint
, the new instance will share it with them. If the
sharing of listening endpoints is not supported by the runtime, falls
back to openAndBindServerSocketChannel(Map, SocketAddress, int)
.properties
- a Map
of the values to be assigned to
properties of the underlying ServerSocketChannel
which is to
actually listen on the specified endpoint
. If the new instance is
not the first to open and bind the specified endpoint
, the
properties
and their respective values may not be used.endpoint
- the IP and port the new instance is to bind tobacklog
- the requested maximum number of pending incoming
connections to be queued. If the new instance is not the first to open
and bind the specified endpoint
, the value may not be used.filter
- the DatagramPacketFilter
to demultiplex (i.e.
recognize) the content meant for the new instanceMuxServerSocketChannel
instance open and bound on
the specified listening endpoint
IOException
- if an I/O error occurspublic static ServerSocketChannel openAndBindServerSocketChannel(Map<String,Object> properties, SocketAddress endpoint, int backlog) throws IOException
ServerSocketChannel
instance.properties
- a Map
of the values to be assigned to
properties of the underlying ServerSocketChannel
which is to
actually listen on the specified endpoint
. If the new instance is
not the first to open and bind the specified endpoint
, the
properties
and their respective values may not be used.endpoint
- the IP and port the new instance is to bind tobacklog
- the requested maximum number of pending incoming
connections to be queued. If the new instance is not the first to open
and bind the specified endpoint
, the value may not be used.ServerSocketChannel
instance open and bound on the
specified listening endpoint
IOException
- if an I/O error occursCopyright © 2018. All rights reserved.