An SCTP channel can only control one SCTP association.
An SCTPChannel is created by invoking one of the
open methods of this class. A newly-created channel is open but
not yet connected, that is, there is no association setup with a remote peer.
An attempt to invoke an I/O operation upon an unconnected
channel will cause a java. to be
thrown. An association can be setup by connecting the channel using one of
its connect methods. Once connected, the channel remains
connected until it is closed. Whether or not a channel is connected may be
determined by invoking getRemoteAddresses.
SCTP channels support non-blocking connection: A
channel may be created and the process of establishing the link to
the remote socket may be initiated via the connect method
for later completion by the finishConnect method.
Whether or not a connection operation is in progress may be determined by
invoking the isConnectionPending method.
Socket options are configured using the
setOption method. An SCTP
channel 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_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 channels are safe for use by multiple concurrent threads.
They support concurrent reading and writing, though at most one thread may be
reading and at most one thread may be writing at any given time. The
connect and finishConnect methods are mutually synchronized against each other, and
an attempt to initiate a send or receive operation while an invocation of one
of these methods is in progress will block until that invocation is complete.
| Access | Constructor and Description |
|---|---|
| protected | SctpChannel(SelectorProvider
The selector provider for this channel provider)Initializes a new instance of this class. |
| Modifier and Type | Method and Description |
|---|---|
| public abstract Association | Returns: the association, ornull if the channel's socket is not
connected.Returns the association on this channel's socket. |
| public abstract SctpChannel | 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. |
| public abstract SctpChannel | 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 boolean | Returns: true if a connection was established, false if
this channel is in non-blocking mode and the connection
operation is in progressThe remote peer to which this channel is to be connected remote)Connects this channel's socket. |
| public abstract boolean | Returns: true if a connection was established, false if
this channel is in non-blocking mode and the connection operation
is in progressThe remote peer to which this channel is to be connected remote, int Must be non negative and no larger than maxOutStreams, int 65536.
0 to use the endpoints default value.Must be non negative and no larger than maxInStreams)65536.
0 to use the endpoints default value.Connects this channel's socket. |
| public abstract boolean | Returns: true if, and only if, this channel's socket is now
connectedFinishes the process of connecting an SCTP channel. |
| 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)Returns the value of a socket option. |
| public abstract Set | Returns: All of the remote addresses to which this channel's socket is connected, or an emptySet if the channel's socket is
not connectedReturns all of the remote addresses to which this channel's socket is connected. |
| public abstract boolean | Returns: true if, and only if, a connection operation has been initiated
on this channel but not yet completed by invoking the
finishConnect methodTells whether or not a connection operation is in progress on this channel. |
| public static SctpChannel | |
| public static SctpChannel | Returns: A new SCTP channel connected to the given addressThe remote address to which the new channel is to be connected remote, int The number of streams that the application wishes to be able
to send to. Must be non negative and no larger than maxOutStreams, int 65536.
0 to use the endpoints default value.The maximum number of inbound streams the application is prepared
to support. Must be non negative and no larger than maxInStreams)65536.
0 to use the endpoints default value.Opens an SCTP channel and connects it to a remote address. |
| 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 message bytes are to be transferred dst, 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 into the given buffer and/or handles a notification. |
| 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 src, 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> SctpChannel | Returns: This channelThe socket option name, T The value of the socket option. A value of value)null may be
a valid value for some socket options.Sets the value of a socket option. |
| public abstract SctpChannel | |
| 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 SctpChannel | 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. |
| SctpChannel | back to summary |
|---|---|
| protected SctpChannel(SelectorProvider provider) Initializes a new instance of this class.
| |
| association | back to summary |
|---|---|
| public abstract Association association() throws IOException Returns the association on this channel's socket.
| |
| bind | back to summary |
|---|---|
| public abstract SctpChannel bind(SocketAddress local) throws IOException Binds the channel's socket to a local address. This method is used to establish a relationship between the socket
and the local addresses. 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
| |
| bindAddress | back to summary |
|---|---|
| public abstract SctpChannel 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 Adding addresses to a connected association 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.
| |
| connect | back to summary |
|---|---|
| public abstract boolean connect(SocketAddress remote) throws IOException Connects this channel's socket. If this channel is in non-blocking mode then an invocation of this
method initiates a non-blocking connection operation. If the connection
is established immediately, as can happen with a local connection, then
this method returns If this channel is in blocking mode then an invocation of this method will block until the connection is established or an I/O error occurs. This method may be invoked at any time. If a
| |
| connect | back to summary |
|---|---|
| public abstract boolean connect(SocketAddress remote, int maxOutStreams, int maxInStreams) throws IOException Connects this channel's socket. This is a convience method and is equivalent to evaluating the following expression: setOption(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS, SctpStandardSocketOption.InitMaxStreams.create(maxInStreams, maxOutStreams)) .connect(remote); The
| |
| finishConnect | back to summary |
|---|---|
| public abstract boolean finishConnect() throws IOException Finishes the process of connecting an SCTP channel. A non-blocking connection operation is initiated by placing a socket
channel in non-blocking mode and then invoking one of its If this channel is already connected then this method will not block
and will immediately return This method may be invoked at any time. If a
| |
| 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) throws IOException Returns the value of a socket option.
| |
| getRemoteAddresses | back to summary |
|---|---|
| public abstract Set Returns all of the remote addresses to which this channel's socket is connected. If the channel is connected to a remote peer that is bound to multiple addresses then it is these addresses that the channel's socket is connected.
| |
| isConnectionPending | back to summary |
|---|---|
| public abstract boolean isConnectionPending() Tells whether or not a connection operation is in progress on this channel.
| |
| open | back to summary |
|---|---|
| public static SctpChannel open() throws IOException Opens an SCTP channel. The new channel is unbound and unconnected.
| |
| open | back to summary |
|---|---|
| public static SctpChannel open(SocketAddress remote, int maxOutStreams, int maxInStreams) throws IOException Opens an SCTP channel and connects it to a remote address. This is a convenience method and is equivalent to evaluating the following expression: open().connect(remote, maxOutStreams, maxInStreams);
| |
| receive | back to summary |
|---|---|
| public abstract <T> MessageInfo receive(ByteBuffer dst, T attachment, NotificationHandler<T> handler) throws IOException Receives a message into the given buffer and/or handles a notification. 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. 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 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 src, MessageInfo messageInfo) throws IOException Sends a message via this channel. If this channel is in non-blocking mode and there is sufficient room
in the underlying output buffer, or if this channel is in blocking mode
and sufficient room becomes available, then the remaining bytes in the
given byte buffer are transmitted as a single message. Sending a message
is atomic unless explicit message completion The message is transferred from the byte buffer as if by a regular
The bytes will be written to the stream number that is specified by
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> SctpChannel setOption(SctpSocketOption<T> name, T value) throws IOException Sets the value of a socket option.
| |
| shutdown | back to summary |
|---|---|
| public abstract SctpChannel shutdown() throws IOException Shutdown a connection without closing the channel. Sends a shutdown command to the remote peer, effectively preventing
any new data from being written to the socket by either peer. Further
sends will throw
| |
| 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 SctpChannel 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 Removing addresses from a connected association 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 channels support connecting, reading, and writing, so this
method returns
| |