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.NetworkChannelA 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 FiberSocketChannelaccept()Accepts a connection.abstract FiberServerSocketChannelbind(java.net.SocketAddress local)Binds the channel's socket to a local address and configures the socket to listen for connections.abstract FiberServerSocketChannelbind(java.net.SocketAddress local, int backlog)Binds the channel's socket to a local address and configures the socket to listen for connections.abstract voidclose()abstract java.net.SocketAddressgetLocalAddress()abstract <T> TgetOption(java.net.SocketOption<T> name)abstract booleanisOpen()static FiberServerSocketChannelopen()Opens a server-socket channel.static FiberServerSocketChannelopen(ChannelGroup group)Opens an server-socket channel.abstract java.lang.Objectprovider()Returns the IO provider that created this channel.abstract <T> FiberServerSocketChannelsetOption(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
nullthen 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, ornullfor 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
FiberSocketChannelto the new connection.When a new connection is accepted then the resulting
FiberSocketChannelwill be bound to the sameChannelGroupas this channel. If the group isshutdownand a connection is accepted, then the connection is closed, and the method throws anIOExceptionwith 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
checkAcceptmethod. 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
FiberSocketChannelto 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.IOExceptionSuspendExecution
-
isOpen
public abstract boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
close
public abstract void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein 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:
bindin interfacejava.nio.channels.NetworkChannel- Parameters:
local- The local address to bind the socket, ornullto bind to an automatically assigned socket address- Returns:
- This channel
- Throws:
java.nio.channels.AlreadyBoundExceptionjava.nio.channels.UnsupportedAddressTypeExceptionjava.lang.SecurityExceptionjava.nio.channels.ClosedChannelExceptionjava.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
backlogparameter 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 thebacklogparameter has the value0, or a negative value, then an implementation specific default is used.- Parameters:
local- The local address to bind the socket, ornullto 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 itscheckListenmethod 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:
setOptionin interfacejava.nio.channels.NetworkChannel- Throws:
java.lang.IllegalArgumentExceptionjava.nio.channels.ClosedChannelExceptionjava.io.IOException
-
getLocalAddress
public abstract java.net.SocketAddress getLocalAddress() throws java.io.IOException- Specified by:
getLocalAddressin 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:
getOptionin interfacejava.nio.channels.NetworkChannel- Throws:
java.io.IOException
-
supportedOptions
public abstract java.util.Set<java.net.SocketOption<?>> supportedOptions()
- Specified by:
supportedOptionsin 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.
-
-