jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java
author chegar
Thu, 16 Apr 2009 17:42:00 +0100
changeset 2542 d859108aea12
child 5506 202f599c92aa
permissions -rw-r--r--
4927640: Implementation of the sctp protocol Summary: An implementation-specific API for the Stream Control Transmission Protocol Reviewed-by: alanb, michaelm, jccollet
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2542
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     1
/*
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     2
 * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     4
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    10
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    15
 * accompanied this code).
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    16
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    20
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    23
 * have any questions.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    24
 */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    25
package com.sun.nio.sctp;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    26
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    27
import java.net.SocketAddress;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    28
import java.net.InetAddress;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    29
import java.io.IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    30
import java.util.Set;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    31
import java.nio.ByteBuffer;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    32
import java.nio.channels.spi.AbstractSelectableChannel;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    33
import java.nio.channels.spi.SelectorProvider;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    34
import java.nio.channels.ClosedChannelException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    35
import java.nio.channels.SelectionKey;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    36
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    37
/**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    38
 * A selectable channel for message-oriented connected SCTP sockets.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    39
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    40
 * <P> An SCTP channel can only control one SCTP association.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    41
 * An {@code SCTPChannel} is created by invoking one of the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    42
 * {@link #open open} methods of this class. A newly-created channel is open but
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    43
 * not yet connected, that is, there is no association setup with a remote peer.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    44
 * An attempt to invoke an I/O operation upon an unconnected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    45
 * channel will cause a {@link java.nio.channels.NotYetConnectedException} to be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    46
 * thrown. An association can be setup by connecting the channel using one of
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    47
 * its {@link #connect connect} methods. Once connected, the channel remains
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    48
 * connected until it is closed. Whether or not a channel is connected may be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    49
 * determined by invoking {@link #getRemoteAddresses getRemoteAddresses}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    50
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    51
 * <p> SCTP channels support <i>non-blocking connection:</i>&nbsp;A
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    52
 * channel may be created and the process of establishing the link to
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    53
 * the remote socket may be initiated via the {@link #connect connect} method
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    54
 * for later completion by the {@link #finishConnect finishConnect} method.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    55
 * Whether or not a connection operation is in progress may be determined by
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    56
 * invoking the {@link #isConnectionPending isConnectionPending} method.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    57
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    58
 * <p> Socket options are configured using the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    59
 * {@link #setOption(SctpSocketOption,Object) setOption} method. An SCTP
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    60
 * channel support the following options:
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    61
 * <blockquote>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    62
 * <table border>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    63
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    64
 *     <th>Option Name</th>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    65
 *     <th>Description</th>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    66
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    67
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    68
 *     <td> {@link SctpStandardSocketOption#SCTP_DISABLE_FRAGMENTS
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    69
 *                                          SCTP_DISABLE_FRAGMENTS} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    70
 *     <td> Enables or disables message fragmentation </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    71
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    72
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    73
 *     <td> {@link SctpStandardSocketOption#SCTP_EXPLICIT_COMPLETE
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    74
 *                                          SCTP_EXPLICIT_COMPLETE} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    75
 *     <td> Enables or disables explicit message completion </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    76
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    77
 *    <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    78
 *     <td> {@link SctpStandardSocketOption#SCTP_FRAGMENT_INTERLEAVE
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    79
 *                                          SCTP_FRAGMENT_INTERLEAVE} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    80
 *     <td> Controls how the presentation of messages occur for the message
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    81
 *          receiver </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    82
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    83
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    84
 *     <td> {@link SctpStandardSocketOption#SCTP_INIT_MAXSTREAMS
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    85
 *                                          SCTP_INIT_MAXSTREAMS} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    86
 *     <td> The maximum number of streams requested by the local endpoint during
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    87
 *          association initialization </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    88
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    89
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    90
 *     <td> {@link SctpStandardSocketOption#SCTP_NODELAY SCTP_NODELAY} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    91
 *     <td> Enables or disable a Nagle-like algorithm </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    92
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    93
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    94
 *     <td> {@link SctpStandardSocketOption#SCTP_PRIMARY_ADDR
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    95
 *                                          SCTP_PRIMARY_ADDR} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    96
 *     <td> Requests that the local SCTP stack use the given peer address as the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    97
 *          association primary </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    98
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
    99
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   100
 *     <td> {@link SctpStandardSocketOption#SCTP_SET_PEER_PRIMARY_ADDR
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   101
 *                                          SCTP_SET_PEER_PRIMARY_ADDR} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   102
 *     <td> Requests that the peer mark the enclosed address as the association
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   103
 *          primary </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   104
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   105
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   106
 *     <td> {@link SctpStandardSocketOption#SO_SNDBUF
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   107
 *                                          SO_SNDBUF} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   108
 *     <td> The size of the socket send buffer </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   109
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   110
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   111
 *     <td> {@link SctpStandardSocketOption#SO_RCVBUF
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   112
 *                                          SO_RCVBUF} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   113
 *     <td> The size of the socket receive buffer </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   114
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   115
 *   <tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   116
 *     <td> {@link SctpStandardSocketOption#SO_LINGER
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   117
 *                                          SO_LINGER} </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   118
 *     <td> Linger on close if data is present (when configured in blocking mode
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   119
 *          only) </td>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   120
 *   </tr>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   121
 * </table>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   122
 * </blockquote>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   123
 * Additional (implementation specific) options may also be supported. The list
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   124
 * of options supported is obtained by invoking the {@link #supportedOptions()
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   125
 * supportedOptions}  method.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   126
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   127
 * <p> SCTP channels are safe for use by multiple concurrent threads.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   128
 * They support concurrent reading and writing, though at most one thread may be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   129
 * reading and at most one thread may be writing at any given time. The
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   130
 * {@link #connect connect} and {@link #finishConnect
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   131
 * finishConnect} methods are mutually synchronized against each other, and
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   132
 * an attempt to initiate a send or receive operation while an invocation of one
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   133
 * of these methods is in progress will block until that invocation is complete.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   134
 *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   135
 * @since 1.7
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   136
 */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   137
public abstract class SctpChannel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   138
    extends AbstractSelectableChannel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   139
{
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   140
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   141
     * Initializes a new instance of this class.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   142
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   143
     * @param  provider
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   144
     *         The selector provider for this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   145
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   146
    protected SctpChannel(SelectorProvider provider) {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   147
        super(provider);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   148
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   149
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   150
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   151
     * Opens an SCTP channel.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   152
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   153
     * <P> The new channel is unbound and unconnected.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   154
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   155
     * @return  A new SCTP channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   156
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   157
     * @throws  UnsupportedOperationException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   158
     *          If the SCTP protocol is not supported
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   159
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   160
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   161
     *          If an I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   162
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   163
    public static SctpChannel open() throws
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   164
        IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   165
        return new sun.nio.ch.SctpChannelImpl((SelectorProvider)null);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   166
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   167
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   168
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   169
     * Opens an SCTP channel and connects it to a remote address.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   170
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   171
     * <P> This is a convenience method and is equivalent to evaluating the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   172
     * following expression:
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   173
     * <blockquote><pre>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   174
     * open().connect(remote, maxOutStreams, maxInStreams);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   175
     * </pre></blockquote>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   176
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   177
     * @param  remote
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   178
     *         The remote address to which the new channel is to be connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   179
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   180
     * @param  maxOutStreams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   181
     *         The number of streams that the application wishes to be able
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   182
     *         to send to. Must be non negative and no larger than {@code 65536}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   183
     *         {@code 0} to use the endpoints default value.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   184
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   185
     * @param  maxInStreams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   186
     *         The maximum number of inbound streams the application is prepared
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   187
     *         to support. Must be non negative and no larger than {@code 65536}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   188
     *         {@code 0} to use the endpoints default value.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   189
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   190
     * @return  A new SCTP channel connected to the given address
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   191
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   192
     * @throws  java.nio.channels.AsynchronousCloseException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   193
     *          If another thread closes this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   194
     *          while the connect operation is in progress
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   195
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   196
     * @throws  java.nio.channels.ClosedByInterruptException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   197
     *          If another thread interrupts the current thread
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   198
     *          while the connect operation is in progress, thereby
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   199
     *          closing the channel and setting the current thread's
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   200
     *          interrupt status
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   201
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   202
     * @throws  java.nio.channels.UnresolvedAddressException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   203
     *          If the given remote address is not fully resolved
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   204
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   205
     * @throws  java.nio.channels.UnsupportedAddressTypeException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   206
     *          If the type of the given remote address is not supported
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   207
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   208
     * @throws  SecurityException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   209
     *          If a security manager has been installed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   210
     *          and it does not permit access to the given remote peer
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   211
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   212
     * @throws  UnsupportedOperationException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   213
     *          If the SCTP protocol is not supported
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   214
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   215
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   216
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   217
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   218
    public static SctpChannel open(SocketAddress remote, int maxOutStreams,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   219
                   int maxInStreams) throws IOException {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   220
        SctpChannel ssc = SctpChannel.open();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   221
        ssc.connect(remote, maxOutStreams, maxInStreams);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   222
        return ssc;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   223
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   224
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   225
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   226
     * Returns the association on this channel's socket.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   227
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   228
     * @return  the association, or {@code null} if the channel's socket is not
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   229
     *          connected.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   230
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   231
     * @throws  ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   232
     *          If the channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   233
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   234
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   235
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   236
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   237
    public abstract Association association() throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   238
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   239
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   240
     * Binds the channel's socket to a local address.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   241
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   242
     * <P> This method is used to establish a relationship between the socket
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   243
     * and the local addresses. Once a relationship is established then
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   244
     * the socket remains bound until the channel is closed. This relationship
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   245
     * may not necesssarily be with the address {@code local} as it may be removed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   246
     * by {@link #unbindAddress unbindAddress}, but there will always be at least
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   247
     * one local address bound to the channel's socket once an invocation of
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   248
     * this method successfully completes.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   249
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   250
     * <P> Once the channel's socket has been successfully bound to a specific
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   251
     * address, that is not automatically assigned, more addresses
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   252
     * may be bound to it using {@link #bindAddress bindAddress}, or removed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   253
     * using {@link #unbindAddress unbindAddress}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   254
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   255
     * @param  local
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   256
     *         The local address to bind the socket, or {@code null} to
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   257
     *         bind the socket to an automatically assigned socket address
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   258
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   259
     * @return  This channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   260
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   261
     * @throws  java.nio.channels.AlreadyConnectedException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   262
     *          If this channel is already connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   263
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   264
     * @throws  java.nio.channels.ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   265
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   266
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   267
     * @throws  java.nio.channels.ConnectionPendingException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   268
     *          If a non-blocking connection operation is already in progress on this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   269
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   270
     * @throws  java.nio.channels.AlreadyBoundException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   271
     *          If this channel is already bound
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   272
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   273
     * @throws  java.nio.channels.UnsupportedAddressTypeException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   274
     *          If the type of the given address is not supported
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   275
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   276
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   277
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   278
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   279
    public abstract SctpChannel bind(SocketAddress local)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   280
        throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   281
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   282
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   283
     * Adds the given address to the bound addresses for the channel's
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   284
     * socket.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   285
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   286
     * <P> The given address must not be the {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   287
     * java.net.InetAddress#isAnyLocalAddress wildcard} address.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   288
     * The channel must be first bound using {@link #bind bind} before
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   289
     * invoking this method, otherwise {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   290
     * java.nio.channels.NotYetBoundException} is thrown. The {@link #bind bind}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   291
     * method takes a {@code SocketAddress} as its argument which typically
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   292
     * contains a port number as well as an address. Addresses subquently bound
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   293
     * using this method are simply addresses as the SCTP port number remains
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   294
     * the same for the lifetime of the channel.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   295
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   296
     * <P> Adding addresses to a connected association is optional functionality.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   297
     * If the endpoint supports dynamic address reconfiguration then it may
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   298
     * send the appropriate message to the peer to change the peers address
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   299
     * lists.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   300
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   301
     * @param  address
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   302
     *         The address to add to the bound addresses for the socket
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   303
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   304
     * @return  This channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   305
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   306
     * @throws  java.nio.channels.ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   307
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   308
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   309
     * @throws  java.nio.channels.ConnectionPendingException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   310
     *          If a non-blocking connection operation is already in progress on
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   311
     *          this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   312
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   313
     * @throws  java.nio.channels.NotYetBoundException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   314
     *          If this channel is not yet bound
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   315
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   316
     * @throws  java.nio.channels.AlreadyBoundException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   317
     *          If this channel is already bound to the given address
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   318
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   319
     * @throws  IllegalArgumentException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   320
     *          If address is {@code null} or the {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   321
     *          java.net.InetAddress#isAnyLocalAddress wildcard} address
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   322
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   323
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   324
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   325
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   326
    public abstract SctpChannel bindAddress(InetAddress address)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   327
         throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   328
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   329
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   330
     * Removes the given address from the bound addresses for the channel's
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   331
     * socket.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   332
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   333
     * <P> The given address must not be the {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   334
     * java.net.InetAddress#isAnyLocalAddress wildcard} address.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   335
     * The channel must be first bound using {@link #bind bind} before
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   336
     * invoking this method, otherwise {@link java.nio.channels.NotYetBoundException}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   337
     * is thrown. If this method is invoked on a channel that does not have
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   338
     * {@code address} as one of its bound addresses or that has only one
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   339
     * local address bound to it, then this method throws
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   340
     * {@link IllegalUnbindException}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   341
     * The initial address that the channel's socket is bound to using {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   342
     * #bind bind} may be removed from the bound addresses for the channel's socket.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   343
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   344
     * <P> Removing addresses from a connected association is optional
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   345
     * functionality. If the endpoint supports dynamic address reconfiguration
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   346
     * then it may send the appropriate message to the peer to change the peers
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   347
     * address lists.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   348
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   349
     * @param  address
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   350
     *         The address to remove from the bound addresses for the socket
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   351
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   352
     * @return  This channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   353
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   354
     * @throws  java.nio.channels.ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   355
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   356
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   357
     * @throws  java.nio.channels.ConnectionPendingException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   358
     *          If a non-blocking connection operation is already in progress on
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   359
     *          this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   360
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   361
     * @throws  java.nio.channels.NotYetBoundException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   362
     *          If this channel is not yet bound
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   363
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   364
     * @throws  IllegalArgumentException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   365
     *          If address is {@code null} or the {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   366
     *          java.net.InetAddress#isAnyLocalAddress wildcard} address
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   367
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   368
     * @throws  IllegalUnbindException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   369
     *          If {@code address} is not bound to the channel's socket. or
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   370
     *          the channel has only one address bound to it
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   371
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   372
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   373
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   374
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   375
    public abstract SctpChannel unbindAddress(InetAddress address)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   376
         throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   377
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   378
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   379
     * Connects this channel's socket.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   380
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   381
     * <P> If this channel is in non-blocking mode then an invocation of this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   382
     * method initiates a non-blocking connection operation.  If the connection
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   383
     * is established immediately, as can happen with a local connection, then
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   384
     * this method returns {@code true}.  Otherwise this method returns
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   385
     * {@code false} and the connection operation must later be completed by
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   386
     * invoking the {@link #finishConnect finishConnect} method.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   387
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   388
     * <P> If this channel is in blocking mode then an invocation of this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   389
     * method will block until the connection is established or an I/O error
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   390
     * occurs.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   391
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   392
     * <P> If a security manager has been installed then this method verifies
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   393
     * that its {@link java.lang.SecurityManager#checkConnect checkConnect}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   394
     * method permits connecting to the address and port number of the given
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   395
     * remote peer.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   396
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   397
     * <p> This method may be invoked at any time. If a {@link #send send} or
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   398
     * {@link #receive receive} operation upon this channel is invoked while an
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   399
     * invocation of this method is in progress then that operation will first
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   400
     * block until this invocation is complete.  If a connection attempt is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   401
     * initiated but fails, that is, if an invocation of this method throws a
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   402
     * checked exception, then the channel will be closed.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   403
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   404
     * @param  remote
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   405
     *         The remote peer to which this channel is to be connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   406
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   407
     * @return  {@code true} if a connection was established, {@code false} if
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   408
     *          this channel is in non-blocking mode and the connection
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   409
     *          operation is in progress
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   410
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   411
     * @throws  java.nio.channels.AlreadyConnectedException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   412
     *          If this channel is already connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   413
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   414
     * @throws  java.nio.channels.ConnectionPendingException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   415
     *          If a non-blocking connection operation is already in progress on
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   416
     *          this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   417
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   418
     * @throws  java.nio.channels.ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   419
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   420
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   421
     * @throws  java.nio.channels.AsynchronousCloseException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   422
     *          If another thread closes this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   423
     *          while the connect operation is in progress
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   424
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   425
     * @throws  java.nio.channels.ClosedByInterruptException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   426
     *          If another thread interrupts the current thread
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   427
     *          while the connect operation is in progress, thereby
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   428
     *          closing the channel and setting the current thread's
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   429
     *          interrupt status
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   430
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   431
     * @throws  java.nio.channels.UnresolvedAddressException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   432
     *          If the given remote address is not fully resolved
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   433
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   434
     * @throws  java.nio.channels.UnsupportedAddressTypeException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   435
     *          If the type of the given remote address is not supported
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   436
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   437
     * @throws  SecurityException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   438
     *          If a security manager has been installed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   439
     *          and it does not permit access to the given remote peer
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   440
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   441
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   442
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   443
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   444
    public abstract boolean connect(SocketAddress remote) throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   445
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   446
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   447
     * Connects this channel's socket.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   448
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   449
     * <P> This is a convience method and is equivalent to evaluating the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   450
     * following expression:
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   451
     * <blockquote><pre>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   452
     * setOption(SctpStandardSocketOption.SCTP_INIT_MAXSTREAMS, SctpStandardSocketOption.InitMaxStreams.create(maxInStreams, maxOutStreams))
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   453
     *  .connect(remote);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   454
     * </pre></blockquote>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   455
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   456
     * <P> The {@code maxOutStreams} and {@code maxInStreams} parameters
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   457
     * represent the maximum number of streams that the application wishes to be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   458
     * able to send to and receive from. They are negotiated with the remote
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   459
     * peer and may be limited by the operating system.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   460
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   461
     * @param  remote
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   462
     *         The remote peer to which this channel is to be connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   463
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   464
     * @param  maxOutStreams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   465
     *         Must be non negative and no larger than {@code 65536}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   466
     *         {@code 0} to use the endpoints default value.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   467
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   468
     * @param  maxInStreams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   469
     *         Must be non negative and no larger than {@code 65536}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   470
     *         {@code 0} to use the endpoints default value.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   471
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   472
     * @return  {@code true} if a connection was established, {@code false} if
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   473
     *          this channel is in non-blocking mode and the connection operation
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   474
     *          is in progress
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   475
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   476
     * @throws  java.nio.channels.AlreadyConnectedException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   477
     *          If this channel is already connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   478
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   479
     * @throws  java.nio.channels.ConnectionPendingException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   480
     *          If a non-blocking connection operation is already in progress on
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   481
     *          this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   482
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   483
     * @throws  java.nio.channels.ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   484
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   485
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   486
     * @throws  java.nio.channels.AsynchronousCloseException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   487
     *          If another thread closes this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   488
     *          while the connect operation is in progress
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   489
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   490
     * @throws  java.nio.channels.ClosedByInterruptException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   491
     *          If another thread interrupts the current thread
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   492
     *          while the connect operation is in progress, thereby
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   493
     *          closing the channel and setting the current thread's
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   494
     *          interrupt status
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   495
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   496
     * @throws  java.nio.channels.UnresolvedAddressException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   497
     *          If the given remote address is not fully resolved
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   498
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   499
     * @throws  java.nio.channels.UnsupportedAddressTypeException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   500
     *          If the type of the given remote address is not supported
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   501
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   502
     * @throws  SecurityException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   503
     *          If a security manager has been installed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   504
     *          and it does not permit access to the given remote peer
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   505
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   506
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   507
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   508
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   509
    public abstract boolean connect(SocketAddress remote,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   510
                                    int maxOutStreams,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   511
                                    int maxInStreams)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   512
        throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   513
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   514
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   515
     * Tells whether or not a connection operation is in progress on this channel.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   516
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   517
     * @return  {@code true} if, and only if, a connection operation has been initiated
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   518
     *          on this channel but not yet completed by invoking the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   519
     *          {@link #finishConnect} method
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   520
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   521
    public abstract boolean isConnectionPending();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   522
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   523
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   524
     * Finishes the process of connecting an SCTP channel.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   525
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   526
     * <P> A non-blocking connection operation is initiated by placing a socket
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   527
     * channel in non-blocking mode and then invoking one of its {@link #connect
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   528
     * connect} methods.  Once the connection is established, or the attempt has
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   529
     * failed, the channel will become connectable and this method may
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   530
     * be invoked to complete the connection sequence.  If the connection
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   531
     * operation failed then invoking this method will cause an appropriate
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   532
     * {@link java.io.IOException} to be thrown.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   533
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   534
     * <P> If this channel is already connected then this method will not block
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   535
     * and will immediately return <tt>true</tt>.  If this channel is in
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   536
     * non-blocking mode then this method will return <tt>false</tt> if the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   537
     * connection process is not yet complete.  If this channel is in blocking
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   538
     * mode then this method will block until the connection either completes
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   539
     * or fails, and will always either return <tt>true</tt> or throw a checked
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   540
     * exception describing the failure.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   541
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   542
     * <P> This method may be invoked at any time. If a {@link #send send} or {@link #receive receive}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   543
     * operation upon this channel is invoked while an invocation of this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   544
     * method is in progress then that operation will first block until this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   545
     * invocation is complete.  If a connection attempt fails, that is, if an
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   546
     * invocation of this method throws a checked exception, then the channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   547
     * will be closed.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   548
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   549
     * @return  {@code true} if, and only if, this channel's socket is now
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   550
     *          connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   551
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   552
     * @throws  java.nio.channels.NoConnectionPendingException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   553
     *          If this channel is not connected and a connection operation
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   554
     *          has not been initiated
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   555
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   556
     * @throws  java.nio.channels.ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   557
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   558
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   559
     * @throws  java.nio.channels.AsynchronousCloseException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   560
     *          If another thread closes this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   561
     *          while the connect operation is in progress
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   562
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   563
     * @throws  java.nio.channels.ClosedByInterruptException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   564
     *          If another thread interrupts the current thread
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   565
     *          while the connect operation is in progress, thereby
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   566
     *          closing the channel and setting the current thread's
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   567
     *          interrupt status
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   568
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   569
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   570
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   571
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   572
    public abstract boolean finishConnect() throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   573
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   574
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   575
     * Returns all of the socket addresses to which this channel's socket is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   576
     * bound.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   577
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   578
     * @return  All the socket addresses that this channel's socket is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   579
     *          bound to, or an empty {@code Set} if the channel's socket is not
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   580
     *          bound
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   581
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   582
     * @throws  ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   583
     *          If the channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   584
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   585
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   586
     *          If an I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   587
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   588
    public abstract Set<SocketAddress> getAllLocalAddresses()
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   589
        throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   590
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   591
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   592
     * Returns all of the remote addresses to which this channel's socket
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   593
     * is connected.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   594
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   595
     * <P> If the channel is connected to a remote peer that is bound to
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   596
     * multiple addresses then it is these addresses that the channel's socket
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   597
     * is connected.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   598
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   599
     * @return  All of the remote addresses to which this channel's socket
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   600
     *          is connected, or an empty {@code Set} if the channel's socket is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   601
     *          not connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   602
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   603
     * @throws  ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   604
     *          If the channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   605
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   606
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   607
     *          If an I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   608
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   609
    public abstract Set<SocketAddress> getRemoteAddresses()
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   610
        throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   611
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   612
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   613
     * Shutdown a connection without closing the channel.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   614
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   615
     * <P> Sends a shutdown command to the remote peer, effectively preventing
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   616
     * any new data from being written to the socket by either peer. Further
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   617
     * sends will throw {@link java.nio.channels.ClosedChannelException}. The
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   618
     * channel remains open to allow the for any data (and notifications) to be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   619
     * received that may have been sent by the peer before it received the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   620
     * shutdown command. If the channel is already shutdown then invoking this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   621
     * method has no effect.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   622
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   623
     * @return  This channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   624
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   625
     * @throws  java.nio.channels.NotYetConnectedException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   626
     *          If this channel is not yet connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   627
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   628
     * @throws  java.nio.channels.ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   629
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   630
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   631
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   632
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   633
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   634
    public abstract SctpChannel shutdown() throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   635
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   636
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   637
     * Returns the value of a socket option.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   638
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   639
     * @param   name
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   640
     *          The socket option
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   641
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   642
     * @return  The value of the socket option. A value of {@code null} may be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   643
     *          a valid value for some socket options.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   644
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   645
     * @throws  UnsupportedOperationException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   646
     *          If the socket option is not supported by this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   647
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   648
     * @throws  ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   649
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   650
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   651
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   652
     *          If an I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   653
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   654
     * @see SctpStandardSocketOption
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   655
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   656
    public abstract <T> T getOption(SctpSocketOption<T> name)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   657
        throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   658
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   659
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   660
     * Sets the value of a socket option.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   661
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   662
     * @param   name
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   663
     *          The socket option
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   664
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   665
     * @param   value
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   666
     *          The value of the socket option. A value of {@code null} may be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   667
     *          a valid value for some socket options.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   668
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   669
     * @return  This channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   670
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   671
     * @throws  UnsupportedOperationException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   672
     *          If the socket option is not supported by this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   673
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   674
     * @throws  IllegalArgumentException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   675
     *          If the value is not a valid value for this socket option
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   676
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   677
     * @throws  ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   678
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   679
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   680
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   681
     *          If an I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   682
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   683
     * @see SctpStandardSocketOption
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   684
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   685
    public abstract <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   686
        throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   687
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   688
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   689
     * Returns a set of the socket options supported by this channel.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   690
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   691
     * <P> This method will continue to return the set of options even after the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   692
     * channel has been closed.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   693
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   694
     * @return  A set of the socket options supported by this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   695
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   696
    public abstract Set<SctpSocketOption<?>> supportedOptions();
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   697
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   698
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   699
     * Returns an operation set identifying this channel's supported operations.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   700
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   701
     * <P> SCTP channels support connecting, reading, and writing, so this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   702
     * method returns <tt>(</tt>{@link SelectionKey#OP_CONNECT}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   703
     * <tt>|</tt>&nbsp;{@link SelectionKey#OP_READ} <tt>|</tt>&nbsp;{@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   704
     * SelectionKey#OP_WRITE}<tt>)</tt>.  </p>
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   705
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   706
     * @return  The valid-operation set
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   707
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   708
    @Override
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   709
    public final int validOps() {
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   710
        return (SelectionKey.OP_READ |
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   711
                SelectionKey.OP_WRITE |
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   712
                SelectionKey.OP_CONNECT);
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   713
    }
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   714
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   715
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   716
     * Receives a message into the given buffer and/or handles a notification.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   717
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   718
     * <P> If a message or notification is immediately available, or if this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   719
     * channel is in blocking mode and one eventually becomes available, then
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   720
     * the message or notification is returned or handled, respectively. If this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   721
     * channel is in non-blocking mode and a message or notification is not
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   722
     * immediately available then this method immediately returns {@code null}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   723
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   724
     * <P> If this method receives a message it is copied into the given byte
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   725
     * buffer. The message is transferred into the given byte buffer starting at
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   726
     * its current position and the buffers position is incremented by the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   727
     * number of bytes read. If there are fewer bytes remaining in the buffer
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   728
     * than are required to hold the message, or the underlying input buffer
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   729
     * does not contain the complete message, then an invocation of {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   730
     * MessageInfo#isComplete isComplete} on the returned {@code
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   731
     * MessageInfo} will return {@code false}, and more invocations of this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   732
     * method will be necessary to completely consume the messgae. Only
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   733
     * one message at a time will be partially delivered in any stream. The
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   734
     * socket option {@link SctpStandardSocketOption#SCTP_FRAGMENT_INTERLEAVE
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   735
     * SCTP_FRAGMENT_INTERLEAVE} controls various aspects of what interlacing of
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   736
     * messages occurs.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   737
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   738
     * <P> If this method receives a notification then the appropriate method of
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   739
     * the given handler, if there is one, is invoked. If the handler returns
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   740
     * {@link HandlerResult#CONTINUE CONTINUE} then this method will try to
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   741
     * receive another message/notification, otherwise, if {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   742
     * HandlerResult#RETURN RETURN} is returned this method will return {@code
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   743
     * null}. If an uncaught exception is thrown by the handler it will be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   744
     * propagated up the stack through this method.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   745
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   746
     * <P> This method may be invoked at any time. If another thread has
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   747
     * already initiated a receive operation upon this channel, then an
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   748
     * invocation of this method will block until the first operation is
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   749
     * complete. The given handler is invoked without holding any locks used
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   750
     * to enforce the above synchronization policy, that way handlers
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   751
     * will not stall other threads from receiving. A handler should not invoke
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   752
     * the {@code receive} method of this channel, if it does an
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   753
     * {@link IllegalReceiveException} will be thrown.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   754
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   755
     * @param  dst
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   756
     *         The buffer into which message bytes are to be transferred
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   757
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   758
     * @param  attachment
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   759
     *         The object to attach to the receive operation; can be
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   760
     *         {@code null}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   761
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   762
     * @param  handler
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   763
     *         A handler to handle notifications from the SCTP stack, or {@code
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   764
     *         null} to ignore any notifications.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   765
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   766
     * @return  The {@code MessageInfo}, {@code null} if this channel is in
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   767
     *          non-blocking mode and no messages are immediately available or
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   768
     *          the notification handler returns {@link HandlerResult#RETURN
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   769
     *          RETURN} after handling a notification
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   770
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   771
     * @throws  java.nio.channels.ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   772
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   773
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   774
     * @throws  java.nio.channels.AsynchronousCloseException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   775
     *          If another thread closes this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   776
     *          while the read operation is in progress
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   777
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   778
     * @throws  java.nio.channels.ClosedByInterruptException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   779
     *          If another thread interrupts the current thread
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   780
     *          while the read operation is in progress, thereby
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   781
     *          closing the channel and setting the current thread's
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   782
     *          interrupt status
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   783
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   784
     * @throws  java.nio.channels.NotYetConnectedException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   785
     *          If this channel is not yet connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   786
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   787
     * @throws  IllegalReceiveException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   788
     *          If the given handler invokes the {@code receive} method of this
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   789
     *          channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   790
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   791
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   792
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   793
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   794
    public abstract <T> MessageInfo receive(ByteBuffer dst,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   795
                                            T attachment,
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   796
                                            NotificationHandler<T> handler)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   797
        throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   798
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   799
    /**
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   800
     * Sends a message via this channel.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   801
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   802
     * <P> If this channel is in non-blocking mode and there is sufficient room
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   803
     * in the underlying output buffer, or if this channel is in blocking mode
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   804
     * and sufficient room becomes available, then the remaining bytes in the
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   805
     * given byte buffer are transmitted as a single message. Sending a message
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   806
     * is atomic unless explicit message completion {@link
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   807
     * SctpStandardSocketOption#SCTP_EXPLICIT_COMPLETE SCTP_EXPLICIT_COMPLETE}
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   808
     * socket option is enabled on this channel's socket.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   809
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   810
     * <P> The message is transferred from the byte buffer as if by a regular
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   811
     * {@link java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   812
     * write} operation.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   813
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   814
     * <P> The bytes will be written to the stream number that is specified by
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   815
     * {@link MessageInfo#streamNumber streamNumber} in the given {@code
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   816
     * messageInfo}.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   817
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   818
     * <P> This method may be invoked at any time. If another thread has already
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   819
     * initiated a send operation upon this channel, then an invocation of
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   820
     * this method will block until the first operation is complete.
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   821
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   822
     * @param  src
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   823
     *         The buffer containing the message to be sent
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   824
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   825
     * @param  messageInfo
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   826
     *         Ancillary data about the message to be sent
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   827
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   828
     * @return  The number of bytes sent, which will be either the number of
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   829
     *          bytes that were remaining in the messages buffer when this method
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   830
     *          was invoked or, if this channel is non-blocking, may be zero if
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   831
     *          there was insufficient room for the message in the underlying
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   832
     *          output buffer
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   833
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   834
     * @throws  InvalidStreamExcepton
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   835
     *          If {@code streamNumner} is negative or greater than or equal to
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   836
     *          the maximum number of outgoing streams
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   837
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   838
     * @throws  java.nio.channels.ClosedChannelException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   839
     *          If this channel is closed
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   840
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   841
     * @throws  java.nio.channels.AsynchronousCloseException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   842
     *          If another thread closes this channel
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   843
     *          while the read operation is in progress
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   844
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   845
     * @throws  java.nio.channels.ClosedByInterruptException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   846
     *          If another thread interrupts the current thread
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   847
     *          while the read operation is in progress, thereby
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   848
     *          closing the channel and setting the current thread's
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   849
     *          interrupt status
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   850
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   851
     * @throws  java.nio.channels.NotYetConnectedException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   852
     *          If this channel is not yet connected
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   853
     *
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   854
     * @throws  IOException
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   855
     *          If some other I/O error occurs
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   856
     */
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   857
    public abstract int send(ByteBuffer src, MessageInfo messageInfo)
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   858
        throws IOException;
d859108aea12 4927640: Implementation of the sctp protocol
chegar
parents:
diff changeset
   859
}