An SCTP multi channel supports many associations on a single socket.
An SctpMultiChannel is created by invoking the
open method of this class. A newly-created channel is open but
not yet bound. An attempt to invoke the receive method of an
unbound channel will cause the NotYetBoundException
to be thrown. An attempt to invoke the send method of an
unbound channel will cause it to first invoke the bind method.
The address(es) that the channel's socket is bound to can be retrieved by
calling getAllLocalAddresses.
Messages may be sent and received without explicitly setting up an
association with the remote peer. The channel will implicitly setup
a new association whenever it sends or receives a message from a remote
peer if there is not already an association with that peer. Upon successful
association setup, an association changed notification will be put to the SCTP stack with its
event parameter set to COMM_UP. This notification can be received by invoking receive.
Socket options are configured using the
setOption method. An
SctpMultiChannel supports 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_DISABLE_FRAGMENTSEnables or disables message fragmentation SCTP_EXPLICIT_COMPLETEEnables or disables explicit message completion SCTP_FRAGMENT_INTERLEAVEControls how the presentation of messages occur for the message receiver SCTP_INIT_MAXSTREAMSThe maximum number of streams requested by the local endpoint during association initialization SCTP_NODELAYEnables or disable a Nagle-like algorithm SCTP_PRIMARY_ADDRRequests that the local SCTP stack use the given peer address as the association primary SCTP_SET_PEER_PRIMARY_ADDRRequests that the peer mark the enclosed address as the association primary SO_SNDBUFThe size of the socket send buffer SO_RCVBUFThe size of the socket receive buffer SO_LINGERLinger on close if data is present (when configured in blocking mode only)
supportedOptions method.
SCTP multi channels are safe for use by multiple concurrent threads. They support concurrent sending and receiving, though at most one thread may be sending and at most one thread may be receiving at any given time.
| Access | Constructor and Description |
|---|---|
| protected | SctpMultiChannel(SelectorProvider
The selector provider for this channel provider)Initializes a new instance of this class. |
| Modifier and Type | Method and Description |
|---|---|
| public abstract Set | Returns: ASet containing the open associations, or an empty
Set if there are none.Returns the open associations on this channel's socket. |
| public abstract SctpMultiChannel | Returns: This channelThe local address to bind the socket, or local, int null to
bind the socket to an automatically assigned socket addressThe maximum number of pending connections backlog)Binds the channel's socket to a local address and configures the socket to listen for connections. |
| public final SctpMultiChannel | Returns: This channelThe local address to bind the socket, or local)null to
bind the socket to an automatically assigned socket addressBinds the channel's socket to a local address and configures the socket to listen for connections. |
| public abstract SctpMultiChannel | Returns: This channelThe 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 SctpChannel | Returns: TheSctpChannelThe association to branch off association)Branches off an association. |
| public abstract Set | Returns: All the socket addresses that this channel's socket is bound to, or an emptySet if the channel's socket is not
boundReturns 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 ofnull may be
a valid value for some socket options.The socket option name, Association The association whose option should be retrieved, or association)null
if this option should be retrieved at the channel's socket level.Returns the value of a socket option. |
| public abstract Set | Returns: All of the remote addresses for the given association, or an emptySet if the association has been shutdownThe association association)Returns all of the remote addresses to which the given association on this channel's socket is connected. |
| public static SctpMultiChannel | |
| public abstract < The type of the attachment T> MessageInfo | Returns: TheMessageInfo, null if this channel is in
non-blocking mode and no messages are immediately available or
the notification handler returns RETURN after handling
a notificationThe buffer into which bytes are to be transferred buffer, T The object to attach to the receive operation; can be
attachment, NotificationHandler<T> nullA handler to handle notifications from the SCTP stack, or
handler)null to ignore any notifications.Receives a message and/or handles a notification via this channel. |
| public abstract int | Returns: The number of bytes sent, which will be either the number of bytes that were remaining in the messages buffer when this method was invoked or, if this channel is non-blocking, may be zero if there was insufficient room for the message in the underlying output bufferThe buffer containing the message to be sent buffer, MessageInfo Ancillary data about the message to be sent messageInfo)Sends a message via this channel. |
| public abstract < The type of the socket option value T> SctpMultiChannel | Returns: This channelThe socket option name, T The value of the socket option. A value of value, Association null may be
a valid value for some socket options.The association whose option should be set, or association)null
if this option should be set at the channel's socket level.Sets the value of a socket option. |
| public abstract SctpMultiChannel | Returns: This channelThe association to shutdown association)Shutdown an association without closing the channel. |
| public abstract Set | Returns: A set of the socket options supported by this channelReturns a set of the socket options supported by this channel. |
| public abstract SctpMultiChannel | Returns: This channelThe 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 setImplements abstract java. Returns an operation set identifying this channel's supported operations. |
| SctpMultiChannel | back to summary |
|---|---|
| protected SctpMultiChannel(SelectorProvider provider) Initializes a new instance of this class.
| |
| associations | back to summary |
|---|---|
| public abstract Set Returns the open associations on this channel's socket. Only associations whose The returned set of associations is a snapshot of the open associations at the time that this method is invoked.
| |
| bind | back to summary |
|---|---|
| public abstract SctpMultiChannel bind(SocketAddress local, int backlog) throws IOException Binds the channel's socket to a local address and configures the socket to listen for connections. 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 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 The backlog parameter is the maximum number of pending connections 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
| |
| bind | back to summary |
|---|---|
| public final SctpMultiChannel bind(SocketAddress local) throws IOException Binds the channel's socket to a local address and configures the socket to listen for connections. This method works as if invoking it were equivalent to evaluating the expression: bind(local, 0);
| |
| bindAddress | back to summary |
|---|---|
| public abstract SctpMultiChannel 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 New associations setup after this method successfully completes will be associated with the given address. Adding addresses to existing associations is optional functionality. If the endpoint supports dynamic address reconfiguration then it may send the appropriate message to the peer to change the peers address lists.
| |
| branch | back to summary |
|---|---|
| public abstract SctpChannel branch(Association association) throws IOException Branches off an association. An application can invoke this method to branch off an association
into a separate channel. The new bound and connected This is particularly useful when, for instance, the application wishes to have a number of sporadic message senders/receivers remain under the original SCTP multi channel but branch off those associations carrying high volume data traffic into their own separate SCTP channels.
| |
| getAllLocalAddresses | back to summary |
|---|---|
| public abstract Set Returns all of the socket addresses to which this channel's socket is bound.
| |
| getOption | back to summary |
|---|---|
| public abstract <T> T getOption(SctpSocketOption<T> name, Association association) throws IOException Returns the value of a socket option. Note that some options are retrieved on the channel's socket,
therefore the
| |
| getRemoteAddresses | back to summary |
|---|---|
| public abstract Set Returns all of the remote addresses to which the given association on this channel's socket is connected.
| |
| open | back to summary |
|---|---|
| public static SctpMultiChannel open() throws IOException Opens an SCTP multi channel. The new channel is unbound.
| |
| receive | back to summary |
|---|---|
| public abstract <T> MessageInfo receive(ByteBuffer buffer, T attachment, NotificationHandler<T> handler) throws IOException Receives a message and/or handles a notification via this channel. If a message or notification is immediately available, or if this
channel is in blocking mode and one eventually becomes available, then
the message or notification is returned or handled, respectively. If this
channel is in non-blocking mode and a message or notification is not
immediately available then this method immediately returns If this method receives a message it is copied into the given byte
buffer and an If this method receives a notification then the appropriate method of
the given handler, if there is one, is invoked. If the handler returns This method may be invoked at any time. If another thread has
already initiated a receive operation upon this channel, then an
invocation of this method will block until the first operation is
complete. The given handler is invoked without holding any locks used
to enforce the above synchronization policy, that way handlers
will not stall other threads from receiving. A handler should not invoke
the
| |
| send | back to summary |
|---|---|
| public abstract int send(ByteBuffer buffer, MessageInfo messageInfo) throws IOException Sends a message via this channel. If this channel is unbound then this method will invoke If there is no association existing between this channel's socket
and the intended receiver, identified by the address in the given messageInfo, then one
will be automatically setup to the intended receiver. This is considered
to be Implicit Association Setup. Upon successful association setup, an
If this channel is in blocking mode, there is sufficient room in the
underlying output buffer, then the remaining bytes in the given byte
buffer are transmitted as a single message. Sending a message
is atomic unless explicit message completion If this channel is in non-blocking mode, there is sufficient room
in the underlying output buffer, and an implicit association setup is
required, then the remaining bytes in the given byte buffer are
transmitted as a single message, subject to The message is transferred from the byte buffer as if by a regular
This method may be invoked at any time. If another thread has already initiated a send operation upon this channel, then an invocation of this method will block until the first operation is complete.
| |
| setOption | back to summary |
|---|---|
| public abstract <T> SctpMultiChannel setOption(SctpSocketOption<T> name, T value, Association association) throws IOException Sets the value of a socket option. Note that some options are retrieved on the channel's socket,
therefore the
| |
| shutdown | back to summary |
|---|---|
| public abstract SctpMultiChannel shutdown(Association association) throws IOException Shutdown an association without closing the channel.
| |
| supportedOptions | back to summary |
|---|---|
| public abstract Set 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.
| |
| unbindAddress | back to summary |
|---|---|
| public abstract SctpMultiChannel 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 If this method is invoked on a channel that does
not have The initial address that the channel's socket is bound to using
New associations setup after this method successfully completes will not be associated with the given address. Removing addresses from existing associations is optional functionality. If the endpoint supports dynamic address reconfiguration then it may send the appropriate message to the peer to change the peers address lists.
| |
| validOps | back to summary |
|---|---|
| public final int validOps() Implements abstract java. Returns an operation set identifying this channel's supported operations. SCTP multi channels support reading, and writing, so this
method returns
| |