APIdia Launch Partner
Top Description Constructors Methods
com.sun.nio.sctp

public abstract Class SctpServerChannel

extends AbstractSelectableChannel
Class Inheritance
Known Direct Subclasses
sun.nio.ch.sctp.SctpServerChannelImpl
Imports
java.net.SocketAddress, .InetAddress, java.io.IOException, java.util.Set, java.nio.channels.SelectionKey, java.nio.channels.spi.SelectorProvider, .AbstractSelectableChannel

A selectable channel for message-oriented listening SCTP sockets.

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 java.nio.channels.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:

Socket options
Option Name Description
SCTP_INIT_MAXSTREAMS The maximum number of streams requested by the local endpoint during association initialization
Additional (implementation specific) options may also be supported. The list of options supported is obtained by invoking the supportedOptions method.

SCTP server channels are safe for use by multiple concurrent threads.

Since
1.7

Constructor Summary

AccessConstructor and Description
protected
SctpServerChannel(SelectorProvider
The selector provider for this channel
provider
)

Initializes a new instance of this class.

Method Summary

Modifier and TypeMethod and Description
public abstract SctpChannel

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
accept
()

Accepts an association on this channel's socket.

public final SctpServerChannel

Returns:

This channel
bind
(SocketAddress
The local address to bind the socket, or null to bind the socket to an automatically assigned socket address
local
)

Binds the channel's socket to a local address and configures the socket to listen for associations.

public abstract SctpServerChannel

Returns:

This channel
bind
(SocketAddress
The local address to bind the socket, or null to bind the socket to an automatically assigned socket address
local
,
int
The maximum number of pending associations
backlog
)

Binds the channel's socket to a local address and configures the socket to listen for associations.

public abstract SctpServerChannel

Returns:

This channel
bindAddress
(InetAddress
The address to add to the bound addresses for the socket
address
)

Adds the given address to the bound addresses for the channel's socket.

public abstract Set<SocketAddress>

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
getAllLocalAddresses
()

Returns all of the socket addresses to which this channel's socket is bound.

public abstract <
The type of the socket option value
T
>
T

Returns:

The value of the socket option. A value of null may be a valid value for some socket options.
getOption
(SctpSocketOption<T>
The socket option
name
)

Returns the value of a socket option.

public static SctpServerChannel

Returns:

A new SCTP server channel
open
()

Opens an SCTP server channel.

public abstract <
The type of the socket option value
T
>
SctpServerChannel

Returns:

This channel
setOption
(SctpSocketOption<T>
The socket option
name
,
T
The value of the socket option. A value of null may be a valid value for some socket options.
value
)

Sets the value of a socket option.

public abstract Set<SctpSocketOption<?>>

Returns:

A set of the socket options supported by this channel
supportedOptions
()

Returns a set of the socket options supported by this channel.

public abstract SctpServerChannel

Returns:

This channel
unbindAddress
(InetAddress
The address to remove from the bound addresses for the socket
address
)

Removes the given address from the bound addresses for the channel's socket.

public final int

Returns:

The valid-operation set
validOps
()

Implements abstract java.nio.channels.SelectableChannel.validOps.

Returns an operation set identifying this channel's supported operations.

Inherited from java.nio.channels.spi.AbstractSelectableChannel:
blockingLockconfigureBlockingimplCloseChannelimplCloseSelectableChannelimplConfigureBlockingisBlockingisRegisteredkeyForproviderregister

Constructor Detail

SctpServerChannelback to summary
protected SctpServerChannel(SelectorProvider provider)

Initializes a new instance of this class.

Parameters
provider:SelectorProvider

The selector provider for this channel

Method Detail

acceptback to summary
public abstract SctpChannel accept() throws IOException

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.

Returns:SctpChannel

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

Exceptions
IOException:
If some other I/O error occurs
ClosedChannelException:
If this channel is closed
AsynchronousCloseException:
If another thread closes this channel while the accept operation is in progress
ClosedByInterruptException:
If another thread interrupts the current thread while the accept operation is in progress, thereby closing the channel and setting the current thread's interrupted status
NotYetBoundException:
If this channel's socket has not yet been bound
bindback to summary
public final SctpServerChannel bind(SocketAddress local) throws IOException

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:SocketAddress

The local address to bind the socket, or null to bind the socket to an automatically assigned socket address

Returns:SctpServerChannel

This channel

Exceptions
IOException:
If some other I/O error occurs
ClosedChannelException:
If this channel is closed
AlreadyBoundException:
If this channel is already bound
UnsupportedAddressTypeException:
If the type of the given address is not supported
bindback to summary
public abstract SctpServerChannel bind(SocketAddress local, int backlog) throws IOException

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 by unbindAddress, 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 using unbindAddress.

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:SocketAddress

The local address to bind the socket, or null to bind the socket to an automatically assigned socket address

backlog:int

The maximum number of pending associations

Returns:SctpServerChannel

This channel

Exceptions
IOException:
If some other I/O error occurs
ClosedChannelException:
If this channel is closed
AlreadyBoundException:
If this channel is already bound
UnsupportedAddressTypeException:
If the type of the given address is not supported
bindAddressback to summary
public abstract SctpServerChannel bindAddress(InetAddress address) throws IOException

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 using bind before invoking this method, otherwise java.nio.channels.NotYetBoundException is thrown. The bind method takes a SocketAddress 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:InetAddress

The address to add to the bound addresses for the socket

Returns:SctpServerChannel

This channel

Exceptions
IOException:
If some other I/O error occurs
ClosedChannelException:
If this channel is closed
NotYetBoundException:
If this channel is not yet bound
AlreadyBoundException:
If this channel is already bound to the given address
IllegalArgumentException:
If address is null or the wildcard address
getAllLocalAddressesback to summary
public abstract Set<SocketAddress> getAllLocalAddresses() throws IOException

Returns all of the socket addresses to which this channel's socket is bound.

Returns:Set<SocketAddress>

All the socket addresses that this channel's socket is bound to, or an empty Set if the channel's socket is not bound

Exceptions
IOException:
If an I/O error occurs
ClosedChannelException:
If the channel is closed
getOptionback to summary
public abstract <T> T getOption(SctpSocketOption<T> name) throws IOException

Returns the value of a socket option.

Parameters
<T>
The type of the socket option value
name:SctpSocketOption<T>

The socket option

Returns:T

The value of the socket option. A value of null may be a valid value for some socket options.

Exceptions
IOException:
If an I/O error occurs
UnsupportedOperationException:
If the socket option is not supported by this channel
ClosedChannelException:
If this channel is closed
See Also
SctpStandardSocketOptions
openback to summary
public static SctpServerChannel open() throws IOException

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:SctpServerChannel

A new SCTP server channel

Exceptions
IOException:
If an I/O error occurs
UnsupportedOperationException:
If the SCTP protocol is not supported
setOptionback to summary
public abstract <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value) throws IOException

Sets the value of a socket option.

Parameters
<T>
The type of the socket option value
name:SctpSocketOption<T>

The socket option

value:T

The value of the socket option. A value of null may be a valid value for some socket options.

Returns:SctpServerChannel

This channel

Exceptions
IOException:
If an I/O error occurs
UnsupportedOperationException:
If the socket option is not supported by this channel
IllegalArgumentException:
If the value is not a valid value for this socket option
ClosedChannelException:
If this channel is closed
See Also
SctpStandardSocketOptions
supportedOptionsback to summary
public abstract Set<SctpSocketOption<?>> 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:Set<SctpSocketOption<?>>

A set of the socket options supported by this channel

unbindAddressback to summary
public abstract SctpServerChannel unbindAddress(InetAddress address) throws IOException

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 using bind before invoking this method, otherwise java.nio.channels.NotYetBoundException is thrown. If this method is invoked on a channel that does not have address as one of its bound addresses, or that has only one local address bound to it, then this method throws IllegalUnbindException. The initial address that the channel's socket is bound to using bind 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:InetAddress

The address to remove from the bound addresses for the socket

Returns:SctpServerChannel

This channel

Exceptions
IOException:
If some other I/O error occurs
ClosedChannelException:
If this channel is closed
NotYetBoundException:
If this channel is not yet bound
IllegalArgumentException:
If address is null or the wildcard address
IllegalUnbindException:
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 it
validOpsback to summary
public final int validOps()

Implements abstract java.nio.channels.SelectableChannel.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 java.nio.channels.SelectionKey#OP_ACCEPT.

Returns:int

The valid-operation set

Annotations
@Override