@Exported public abstract class SctpMultiChannel extends AbstractSelectableChannel
 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.
| Modifier | Constructor and Description | 
|---|---|
| protected  | SctpMultiChannel(SelectorProvider provider)Initializes a new instance of this class. | 
| Modifier and Type | Method and Description | 
|---|---|
| abstract Set<Association> | associations()Returns the open associations on this channel's socket. | 
| SctpMultiChannel | bind(SocketAddress local)Binds the channel's socket to a local address and configures the socket
 to listen for connections. | 
| abstract SctpMultiChannel | bind(SocketAddress local,
    int backlog)Binds the channel's socket to a local address and configures the socket
 to listen for connections. | 
| abstract SctpMultiChannel | bindAddress(InetAddress address)Adds the given address to the bound addresses for the channel's
 socket. | 
| abstract SctpChannel | branch(Association association)Branches off an association. | 
| abstract Set<SocketAddress> | getAllLocalAddresses()Returns all of the socket addresses to which this channel's socket is
 bound. | 
| abstract <T> T | getOption(SctpSocketOption<T> name,
         Association association)Returns the value of a socket option. | 
| abstract Set<SocketAddress> | getRemoteAddresses(Association association)Returns all of the remote addresses to which the given association on
 this channel's socket is connected. | 
| static SctpMultiChannel | open()Opens an SCTP multi channel. | 
| abstract <T> MessageInfo | receive(ByteBuffer buffer,
       T attachment,
       NotificationHandler<T> handler)Receives a message and/or handles a notification via this channel. | 
| abstract int | send(ByteBuffer buffer,
    MessageInfo messageInfo)Sends a message via this channel. | 
| abstract <T> SctpMultiChannel | setOption(SctpSocketOption<T> name,
         T value,
         Association association)Sets the value of a socket option. | 
| abstract SctpMultiChannel | shutdown(Association association)Shutdown an association without closing the channel. | 
| abstract Set<SctpSocketOption<?>> | supportedOptions()Returns a set of the socket options supported by this channel. | 
| abstract SctpMultiChannel | unbindAddress(InetAddress address)Removes the given address from the bound addresses for the channel's
 socket. | 
| int | validOps()Returns an operation set identifying this channel's supported operations. | 
blockingLock, configureBlocking, implCloseChannel, implCloseSelectableChannel, implConfigureBlocking, isBlocking, isRegistered, keyFor, provider, registerregisterbegin, close, end, isOpenprotected SctpMultiChannel(SelectorProvider provider)
provider - The selector provider for this channelpublic static SctpMultiChannel open() throws IOException
The new channel is unbound.
UnsupportedOperationException - If the SCTP protocol is not supportedIOException - If an I/O error occurspublic abstract Set<Association> associations() throws IOException
 Only associations whose COMM_UP association change event has been received are included
 in the returned set of associations. Associations for which a
 COMM_LOST or SHUTDOWN association change
 event have been receive are removed from the set of associations.
 
The returned set of associations is a snapshot of the open associations at the time that this method is invoked.
Set containing the open associations, or an empty
          Set if there are none.ClosedChannelException - If this channel is closedIOException - If some other I/O error occurspublic abstract SctpMultiChannel bind(SocketAddress local, int backlog) throws IOException
 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 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 0, or a negative
 value, then an implementation specific default is used.
local - The local address to bind the socket, or null to
         bind the socket to an automatically assigned socket addressbacklog - The maximum number number of pending connectionsClosedChannelException - 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 its checkListen method
          denies the operationIOException - If some other I/O error occurspublic final SctpMultiChannel bind(SocketAddress local) throws IOException
This method works as if invoking it were equivalent to evaluating the expression:
bind(local, 0);
local - The local address to bind the socket, or null to
         bind the socket to an automatically assigned socket addressClosedChannelException - 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 its checkListen method
          denies the operationIOException - If some other I/O error occurspublic abstract SctpMultiChannel bindAddress(InetAddress address) throws IOException
 The given address must not be the wildcard address.
 The channel must be first bound using bind before
 invoking this method, otherwise 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 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.
address - The address to add to the bound addresses for the socketClosedChannelException - If this channel is closedNotYetBoundException - If this channel is not yet boundAlreadyBoundException - If this channel is already bound to the given addressIllegalArgumentException - If address is null or the wildcard addressIOException - If some other I/O error occurspublic abstract SctpMultiChannel unbindAddress(InetAddress address) throws IOException
 The given address must not be the wildcard address.
 The channel must be first bound using bind before
 invoking this method, otherwise 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 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.
address - The address to remove from the bound addresses for the socketClosedChannelException - If this channel is closedNotYetBoundException - If this channel is not yet boundIllegalUnbindException - address is not bound to the channel's socket, or the
          channel has only one address  bound to itIllegalArgumentException - If address is null or the wildcard addressIOException - If some other I/O error occurspublic abstract Set<SocketAddress> getAllLocalAddresses() throws IOException
Set if the channel's socket is not
          boundClosedChannelException - If the channel is closedIOException - If an I/O error occurspublic abstract Set<SocketAddress> getRemoteAddresses(Association association) throws IOException
association - The associationSet if the association has been shutdownClosedChannelException - If the channel is closedIOException - If an I/O error occurspublic abstract SctpMultiChannel shutdown(Association association) throws IOException
association - The association to shutdownClosedChannelException - If this channel is closedIOException - If some other I/O error occurspublic abstract <T> T getOption(SctpSocketOption<T> name, Association association) throws IOException
 Note that some options are retrieved on the channel's socket,
 therefore the association parameter is not applicable and will be
 ignored if given. However, if the option is association specific then the
 association must be given.
T - The type of the socket option valuename - The socket optionassociation - The association whose option should be retrieved, or null
         if this option should be retrieved at the channel's socket level.null may be
          a valid value for some socket options.UnsupportedOperationException - If the socket option is not supported by this channelClosedChannelException - If this channel is closedIOException - If an I/O error occursSctpStandardSocketOptionspublic abstract <T> SctpMultiChannel setOption(SctpSocketOption<T> name, T value, Association association) throws IOException
 Note that some options are retrieved on the channel's socket,
 therefore the association parameter is not applicable and will be
 ignored if given. However, if the option is association specific then the
 association must be given.
T - The type of the socket option valuename - The socket optionassociation - The association whose option should be set, or null
         if this option should be set at the channel's socket level.value - The value of the socket option. A value of null may be
          a valid value for some socket options.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 occursSctpStandardSocketOptionspublic abstract Set<SctpSocketOption<?>> supportedOptions()
This method will continue to return the set of options even after the channel has been closed.
public final int validOps()
 SCTP multi channels support reading, and writing, so this
 method returns
 (SelectionKey.OP_READ | SelectionKey.OP_WRITE).  
validOps in class SelectableChannelpublic abstract <T> MessageInfo receive(ByteBuffer buffer, T attachment, NotificationHandler<T> handler) throws IOException
 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 null.
 
 If this method receives a message it is copied into the given byte
 buffer and an MessageInfo is returned.
 The message is transferred into the given byte buffer starting at its
 current position and the buffers position is incremented by the number of
 bytes read. If there are fewer bytes remaining in the buffer than are
 required to hold the message, or the underlying input buffer does not
 contain the complete message, then an invocation of isComplete on the returned MessageInfo will return false, and more invocations of this
 method will be necessary to completely consume the messgae. Only
 one message at a time will be partially delivered in any stream. The
 socket option SCTP_FRAGMENT_INTERLEAVE controls various aspects of what interlacing of
 messages occurs.
 
 If this method receives a notification then the appropriate method of
 the given handler, if there is one, is invoked. If the handler returns CONTINUE then this method will try to receive another
 message/notification, otherwise, if RETURN is returned
 this method will return null. If an uncaught exception is thrown by the
 handler it will be propagated up the stack through this method.
 
 If a security manager has been installed then for each new association
 setup this method verifies that the associations source address and port
 number are permitted by the security manager's checkAccept method.
 
 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 receive method of this channel, if it does an
 IllegalReceiveException will be thrown.
T - The type of the attachmentbuffer - The buffer into which bytes are to be transferredattachment - The object to attach to the receive operation; can be
         nullhandler - A handler to handle notifications from the SCTP stack, or
         null to ignore any notifications.MessageInfo, null if this channel is in
          non-blocking mode and no messages are immediately available or
          the notification handler returns RETURN after handling
          a notificationClosedChannelException - If this channel is closedAsynchronousCloseException - If another thread closes this channel
          while the read operation is in progressClosedByInterruptException - If another thread interrupts the current thread
          while the read operation is in progress, thereby
          closing the channel and setting the current thread's
          interrupt statusNotYetBoundException - If this channel is not yet boundIllegalReceiveException - If the given handler invokes the receive method of this
          channelSecurityException - If a security manager has been installed and it does not permit
          new associations to be accepted from the message's senderIOException - If some other I/O error occurspublic abstract int send(ByteBuffer buffer, MessageInfo messageInfo) throws IOException
 If this channel is unbound then this method will invoke bind(null, 0) before sending any data.
 
 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
 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.
 
 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 SCTP_EXPLICIT_COMPLETE
 socket option is enabled on this channel's socket.
 
 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 SCTP_EXPLICIT_COMPLETE.
 If for any reason the message cannot
 be delivered an association
 changed notification is put on the SCTP stack with its event parameter set
 to CANT_START.
 
 The message is transferred from the byte buffer as if by a regular
 write operation.
 
 If a security manager has been installed then for each new association
 setup this method verifies that the given remote peers address and port
 number are permitted by the security manager's checkConnect method.
 
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.
buffer - The buffer containing the message to be sentmessageInfo - Ancillary data about the message to be sentInvalidStreamException - If streamNumber is negative, or if an association already
          exists and streamNumber is greater than the maximum number
          of outgoing streamsClosedChannelException - If this channel is closedAsynchronousCloseException - If another thread closes this channel
          while the read operation is in progressClosedByInterruptException - If another thread interrupts the current thread
          while the read operation is in progress, thereby
          closing the channel and setting the current thread's
          interrupt statusSecurityException - If a security manager has been installed and it does not permit
          new associations to be setup with the the messages's addressIOException - If some other I/O error occurspublic abstract SctpChannel branch(Association association) throws IOException
 An application can invoke this method to branch off an association
 into a separate channel. The new bound and connected SctpChannel
 will be created for the association. The branched off association will no
 longer be part of this channel.
 
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.
association - The association to branch offSctpChannelClosedChannelException - If this channel is closedIOException - If some other I/O error occurs
 Copyright © 2009, 2017, Oracle and/or its affiliates.  All rights reserved.