Class FiberServerSocketChannel
- java.lang.Object
-
- co.paralleluniverse.fibers.io.FiberServerSocketChannel
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.Channel
,java.nio.channels.NetworkChannel
public abstract class FiberServerSocketChannel extends java.lang.Object implements java.nio.channels.NetworkChannel
A fiber-blocking version ofServerSocketChannel
.
-
-
Constructor Summary
Constructors Constructor Description FiberServerSocketChannel()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract FiberSocketChannel
accept()
Accepts a connection.abstract FiberServerSocketChannel
bind(java.net.SocketAddress local)
Binds the channel's socket to a local address and configures the socket to listen for connections.abstract FiberServerSocketChannel
bind(java.net.SocketAddress local, int backlog)
Binds the channel's socket to a local address and configures the socket to listen for connections.abstract void
close()
abstract java.net.SocketAddress
getLocalAddress()
abstract <T> T
getOption(java.net.SocketOption<T> name)
abstract boolean
isOpen()
static FiberServerSocketChannel
open()
Opens a server-socket channel.static FiberServerSocketChannel
open(ChannelGroup group)
Opens an server-socket channel.abstract java.lang.Object
provider()
Returns the IO provider that created this channel.abstract <T> FiberServerSocketChannel
setOption(java.net.SocketOption<T> name, T value)
abstract java.util.Set<java.net.SocketOption<?>>
supportedOptions()
-
-
-
Method Detail
-
open
public static FiberServerSocketChannel open(ChannelGroup group) throws java.io.IOException, SuspendExecution
Opens an server-socket channel.If the group parameter is
null
then the resulting channel is created by the system-wide default provider, and bound to the default group.- Parameters:
group
- The group to which the newly constructed channel should be bound, ornull
for the default group- Returns:
- A new server socket channel
- Throws:
java.nio.channels.ShutdownChannelGroupException
- If the channel group is shutdownjava.io.IOException
- If an I/O error occursSuspendExecution
-
open
public static FiberServerSocketChannel open() throws java.io.IOException, SuspendExecution
Opens a server-socket channel. Same asopen((AsynchronousChannelGroup) null)
.- Returns:
- A new server socket channel
- Throws:
java.io.IOException
- If an I/O error occursSuspendExecution
-
accept
public abstract FiberSocketChannel accept() throws java.io.IOException, SuspendExecution
Accepts a connection.This method accepts a connection made to this channel's socket. The returned result is the
FiberSocketChannel
to the new connection.When a new connection is accepted then the resulting
FiberSocketChannel
will be bound to the sameChannelGroup
as this channel. If the group isshutdown
and a connection is accepted, then the connection is closed, and the method throws anIOException
with causeShutdownChannelGroupException
.If a security manager has been installed then it verifies that the address and port number of the connection's remote endpoint are permitted by the security manager's
checkAccept
method. The permission check is performed with privileges that are restricted by the calling context of this method. If the permission check fails then the connection is closed and the operation completes with aSecurityException
.- Returns:
- the
FiberSocketChannel
to the new connection. - Throws:
java.nio.channels.AcceptPendingException
- If an accept operation is already in progress on this channeljava.nio.channels.NotYetBoundException
- If this channel's socket has not yet been boundjava.nio.channels.ShutdownChannelGroupException
- If the channel group has terminatedjava.io.IOException
SuspendExecution
-
isOpen
public abstract boolean isOpen()
- Specified by:
isOpen
in interfacejava.nio.channels.Channel
-
close
public abstract void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.nio.channels.Channel
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
bind
public abstract FiberServerSocketChannel bind(java.net.SocketAddress local) throws java.io.IOException
Binds the channel's socket to a local address and configures the socket to listen for connections.An invocation of this method is equivalent to the following:
bind(local, 0);
- Specified by:
bind
in interfacejava.nio.channels.NetworkChannel
- Parameters:
local
- The local address to bind the socket, ornull
to bind to an automatically assigned socket address- Returns:
- This channel
- Throws:
java.nio.channels.AlreadyBoundException
java.nio.channels.UnsupportedAddressTypeException
java.lang.SecurityException
java.nio.channels.ClosedChannelException
java.io.IOException
-
bind
public abstract FiberServerSocketChannel bind(java.net.SocketAddress local, int backlog) throws java.io.IOException
Binds the channel's socket to a local address and configures the socket to listen for connections.This method is used to establish an association between the socket and a local address. Once an association is established then the socket remains bound until the associated channel is closed.
The
backlog
parameter is the maximum number of pending connections on the socket. Its exact semantics are implementation specific. In particular, an implementation may impose a maximum length or may choose to ignore the parameter altogther. If thebacklog
parameter has the value0
, or a negative value, then an implementation specific default is used.- Parameters:
local
- The local address to bind the socket, ornull
to bind to an automatically assigned socket addressbacklog
- The maximum number of pending connections- Returns:
- This channel
- Throws:
java.nio.channels.AlreadyBoundException
- If the socket is already boundjava.nio.channels.UnsupportedAddressTypeException
- If the type of the given address is not supportedjava.lang.SecurityException
- If a security manager has been installed and itscheckListen
method denies the operationjava.nio.channels.ClosedChannelException
- If the channel is closedjava.io.IOException
- If some other I/O error occurs
-
setOption
public abstract <T> FiberServerSocketChannel setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException
- Specified by:
setOption
in interfacejava.nio.channels.NetworkChannel
- Throws:
java.lang.IllegalArgumentException
java.nio.channels.ClosedChannelException
java.io.IOException
-
getLocalAddress
public abstract java.net.SocketAddress getLocalAddress() throws java.io.IOException
- Specified by:
getLocalAddress
in interfacejava.nio.channels.NetworkChannel
- Throws:
java.io.IOException
-
getOption
public abstract <T> T getOption(java.net.SocketOption<T> name) throws java.io.IOException
- Specified by:
getOption
in interfacejava.nio.channels.NetworkChannel
- Throws:
java.io.IOException
-
supportedOptions
public abstract java.util.Set<java.net.SocketOption<?>> supportedOptions()
- Specified by:
supportedOptions
in interfacejava.nio.channels.NetworkChannel
-
provider
public abstract java.lang.Object provider()
Returns the IO provider that created this channel. The type of the returned value is implementation dependent, and may benull
.
-
-