- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,InterruptibleChannel
An SCTPServerChannel
is created by invoking the
open
method of this class. A newly-created SCTP server
channel is open but not yet bound. An attempt to invoke the
accept
method of an unbound channel will cause the
NotYetBoundException
to be thrown. An SCTP server
channel can be bound by invoking one of the
bind
methods defined by this class.
Socket options are configured using the
setOption
method. SCTP server socket
channels support the following options:
Additional (implementation specific) options may also be supported. The list of options supported is obtained by invoking the
Option Name Description SCTP_INIT_MAXSTREAMS
The maximum number of streams requested by the local endpoint during association initialization
supportedOptions
method.
SCTP server channels are safe for use by multiple concurrent threads.
- Since:
- 1.7
-
Constructor Summary
ModifierConstructorDescriptionprotected
SctpServerChannel
(SelectorProvider provider) Initializes a new instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionabstract SctpChannel
accept()
Accepts an association on this channel's socket.final SctpServerChannel
bind
(SocketAddress local) Binds the channel's socket to a local address and configures the socket to listen for associations.abstract SctpServerChannel
bind
(SocketAddress local, int backlog) Binds the channel's socket to a local address and configures the socket to listen for associations.abstract SctpServerChannel
bindAddress
(InetAddress address) Adds the given address to the bound addresses for the channel's socket.abstract Set
<SocketAddress> Returns all of the socket addresses to which this channel's socket is bound.abstract <T> T
getOption
(SctpSocketOption<T> name) Returns the value of a socket option.static SctpServerChannel
open()
Opens an SCTP server channel.abstract <T> SctpServerChannel
setOption
(SctpSocketOption<T> name, T value) Sets the value of a socket option.abstract Set
<SctpSocketOption<?>> Returns a set of the socket options supported by this channel.abstract SctpServerChannel
unbindAddress
(InetAddress address) Removes the given address from the bound addresses for the channel's socket.final int
validOps()
Returns an operation set identifying this channel's supported operations.Methods declared in class java.nio.channels.spi.AbstractSelectableChannel
blockingLock, configureBlocking, implCloseChannel, implCloseSelectableChannel, implConfigureBlocking, isBlocking, isRegistered, keyFor, provider, register
Methods declared in class java.nio.channels.SelectableChannel
register
Methods declared in class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
Constructor Details
-
SctpServerChannel
Initializes a new instance of this class.- Parameters:
provider
- The selector provider for this channel
-
-
Method Details
-
open
Opens an SCTP server channel.The new channel's socket is initially unbound; it must be bound to a specific address via one of its socket's
bind
methods before associations can be accepted.- Returns:
- A new SCTP server channel
- Throws:
UnsupportedOperationException
- If the SCTP protocol is not supportedIOException
- If an I/O error occurs
-
accept
Accepts an association on this channel's socket.If this channel is in non-blocking mode then this method will immediately return
null
if there are no pending associations. Otherwise it will block indefinitely until a new association is available or an I/O error occurs.The
SCTPChannel
returned by this method, if any, will be in blocking mode regardless of the blocking mode of this channel.If a security manager has been installed then for each new association this method verifies that the address and port number of the assocaitions's remote peer are permitted by the security manager's
checkAccept
method.- Returns:
- The SCTP channel for the new association, or
null
if this channel is in non-blocking mode and no association is available to be accepted - Throws:
ClosedChannelException
- If this channel is closedAsynchronousCloseException
- If another thread closes this channel while the accept operation is in progressClosedByInterruptException
- If another thread interrupts the current thread while the accept operation is in progress, thereby closing the channel and setting the current thread's interrupt statusNotYetBoundException
- If this channel's socket has not yet been boundSecurityException
- If a security manager has been installed and it does not permit access to the remote peer of the new associationIOException
- If some other I/O error occurs
-
bind
Binds the channel's socket to a local address and configures the socket to listen for associations.This method works as if invoking it were equivalent to evaluating the expression:
bind(local, 0);
- Parameters:
local
- The local address to bind the socket, ornull
to bind the socket to an automatically assigned socket address- Returns:
- This channel
- Throws:
ClosedChannelException
- If this channel is closedAlreadyBoundException
- If this channel is already boundUnsupportedAddressTypeException
- If the type of the given address is not supportedSecurityException
- If a security manager has been installed and itscheckListen
method denies the operationIOException
- If some other I/O error occurs
-
bind
Binds the channel's socket to a local address and configures the socket to listen for associations.This method is used to establish a relationship between the socket and the local address. Once a relationship is established then the socket remains bound until the channel is closed. This relationship may not necesssarily be with the address
local
as it may be removed byunbindAddress
, but there will always be at least one local address bound to the channel's socket once an invocation of this method successfully completes.Once the channel's socket has been successfully bound to a specific address, that is not automatically assigned, more addresses may be bound to it using
bindAddress
, or removed usingunbindAddress
.The backlog parameter is the maximum number of pending associations on the socket. Its exact semantics are implementation specific. An implementation may impose an implementation specific maximum length or may choose to ignore the parameter. If the backlog parameter has the value
0
, or a negative value, then an implementation specific default is used.- Parameters:
local
- The local address to bind the socket, ornull
to bind the socket to an automatically assigned socket addressbacklog
- The maximum number of pending associations- Returns:
- This channel
- Throws:
ClosedChannelException
- If this channel is closedAlreadyBoundException
- If this channel is already boundUnsupportedAddressTypeException
- If the type of the given address is not supportedSecurityException
- If a security manager has been installed and itscheckListen
method denies the operationIOException
- If some other I/O error occurs
-
bindAddress
Adds the given address to the bound addresses for the channel's socket.The given address must not be the
wildcard
address. The channel must be first bound usingbind
before invoking this method, otherwiseNotYetBoundException
is thrown. Thebind
method takes aSocketAddress
as its argument which typically contains a port number as well as an address. Addresses subquently bound using this method are simply addresses as the SCTP port number remains the same for the lifetime of the channel.New associations accepted after this method successfully completes will be associated with the given address.
- Parameters:
address
- The address to add to the bound addresses for the socket- Returns:
- This channel
- Throws:
ClosedChannelException
- If this channel is closedNotYetBoundException
- If this channel is not yet boundAlreadyBoundException
- If this channel is already bound to the given addressIllegalArgumentException
- If address isnull
or thewildcard
addressIOException
- If some other I/O error occurs
-
unbindAddress
Removes the given address from the bound addresses for the channel's socket.The given address must not be the
wildcard
address. The channel must be first bound usingbind
before invoking this method, otherwiseNotYetBoundException
is thrown. If this method is invoked on a channel that does not haveaddress
as one of its bound addresses, or that has only one local address bound to it, then this method throwsIllegalUnbindException
. The initial address that the channel's socket is bound to usingbind
may be removed from the bound addresses for the channel's socket.New associations accepted after this method successfully completes will not be associated with the given address.
- Parameters:
address
- The address to remove from the bound addresses for the socket- Returns:
- This channel
- Throws:
ClosedChannelException
- If this channel is closedNotYetBoundException
- If this channel is not yet boundIllegalArgumentException
- If address isnull
or thewildcard
addressIllegalUnbindException
- If the implementation does not support removing addresses from a listening socket,address
is not bound to the channel's socket, or the channel has only one address bound to itIOException
- If some other I/O error occurs
-
getAllLocalAddresses
Returns all of the socket addresses to which this channel's socket is bound.- Returns:
- All the socket addresses that this channel's socket is
bound to, or an empty
Set
if the channel's socket is not bound - Throws:
ClosedChannelException
- If the channel is closedIOException
- If an I/O error occurs
-
getOption
Returns the value of a socket option.- Type Parameters:
T
- The type of the socket option value- Parameters:
name
- The socket option- Returns:
- The value of the socket option. A value of
null
may be a valid value for some socket options. - Throws:
UnsupportedOperationException
- If the socket option is not supported by this channelClosedChannelException
- If this channel is closedIOException
- If an I/O error occurs- See Also:
-
setOption
public abstract <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value) throws IOException Sets the value of a socket option.- Type Parameters:
T
- The type of the socket option value- Parameters:
name
- The socket optionvalue
- The value of the socket option. A value ofnull
may be a valid value for some socket options.- Returns:
- This channel
- Throws:
UnsupportedOperationException
- If the socket option is not supported by this channelIllegalArgumentException
- If the value is not a valid value for this socket optionClosedChannelException
- If this channel is closedIOException
- If an I/O error occurs- See Also:
-
supportedOptions
Returns a set of the socket options supported by this channel.This method will continue to return the set of options even after the channel has been closed.
- Returns:
- A set of the socket options supported by this channel
-
validOps
public final int validOps()Returns an operation set identifying this channel's supported operations.SCTP server channels only support the accepting of new associations, so this method returns
SelectionKey.OP_ACCEPT
.- Specified by:
validOps
in classSelectableChannel
- Returns:
- The valid-operation set
-