77 * For a connected {@code SctpChannel} the address is the 78 * preferred peer address of the association to send the message 79 * to, or {@code null} to use the peer primary address. For an 80 * {@code SctpMultiChannel} the address is used to determine 81 * the association, or if no association exists with a peer of that 82 * address then one is setup. 83 * 84 * @param streamNumber 85 * The stream number that the message will be sent on 86 * 87 * @return The outgoing message info 88 * 89 * @throws IllegalArgumentException 90 * If the streamNumber is negative or greater than {@code 65536} 91 */ 92 public static MessageInfo createOutgoing(SocketAddress address, 93 int streamNumber) { 94 if (streamNumber < 0 || streamNumber > 65536) 95 throw new IllegalArgumentException("Invalid stream number"); 96 97 return new sun.nio.ch.SctpMessageInfoImpl(null, address, streamNumber); 98 } 99 /** 100 * Creates a {@code MessageInfo} instance suitable for use when 101 * sending a message to a given association. Typically used for 102 * {@code SctpMultiChannel} when an association has already been setup. 103 * 104 * <P> The returned instance will have its {@link #isUnordered() unordered} 105 * value set to {@code false}, its {@link #timeToLive() timeToLive} value 106 * set to {@code 0}, its {@link #isComplete() complete} value set 107 * to {@code true}, and its {@link #payloadProtocolID() payloadProtocolID} 108 * value set to {@code 0}. These values, if required, can be set through 109 * the appropriate setter method before sending the message. 110 * 111 * @param association 112 * The association to send the message on 113 * 114 * @param address 115 * The preferred peer address of the association to send the message 116 * to, or {@code null} to use the peer primary address 117 * 118 * @param streamNumber 119 * The stream number that the message will be sent on. 120 * 121 * @return The outgoing message info 122 * 123 * @throws IllegalArgumentException 124 * If {@code association} is {@code null}, or the streamNumber is 125 * negative or greater than {@code 65536} 126 */ 127 public static MessageInfo createOutgoing(Association association, 128 SocketAddress address, 129 int streamNumber) { 130 if (association == null) 131 throw new IllegalArgumentException("association cannot be null"); 132 133 if (streamNumber < 0 || streamNumber > 65536) 134 throw new IllegalArgumentException("Invalid stream number"); 135 136 return new sun.nio.ch.SctpMessageInfoImpl(association, address, 137 streamNumber); 138 } 139 140 /** 141 * Returns the source socket address if the message has been received, 142 * otherwise the preferred destination of the message to be sent. 143 * 144 * @return The socket address, or {@code null} if this instance is to be 145 * used for sending a message and has been construced without 146 * specifying a preferred destination address 147 * 148 */ 149 public abstract SocketAddress address(); 150 151 /** 152 * Returns the association that the message was received on, if the message 153 * has been received, otherwise the association that the message is to be 154 * sent on. 155 * 156 * @return The association, or {@code null} if this instance is to be 157 * used for sending a message and has been construced using the | 77 * For a connected {@code SctpChannel} the address is the 78 * preferred peer address of the association to send the message 79 * to, or {@code null} to use the peer primary address. For an 80 * {@code SctpMultiChannel} the address is used to determine 81 * the association, or if no association exists with a peer of that 82 * address then one is setup. 83 * 84 * @param streamNumber 85 * The stream number that the message will be sent on 86 * 87 * @return The outgoing message info 88 * 89 * @throws IllegalArgumentException 90 * If the streamNumber is negative or greater than {@code 65536} 91 */ 92 public static MessageInfo createOutgoing(SocketAddress address, 93 int streamNumber) { 94 if (streamNumber < 0 || streamNumber > 65536) 95 throw new IllegalArgumentException("Invalid stream number"); 96 97 return new sun.nio.ch.sctp.SctpMessageInfoImpl(null, address, streamNumber); 98 } 99 /** 100 * Creates a {@code MessageInfo} instance suitable for use when 101 * sending a message to a given association. Typically used for 102 * {@code SctpMultiChannel} when an association has already been setup. 103 * 104 * <P> The returned instance will have its {@link #isUnordered() unordered} 105 * value set to {@code false}, its {@link #timeToLive() timeToLive} value 106 * set to {@code 0}, its {@link #isComplete() complete} value set 107 * to {@code true}, and its {@link #payloadProtocolID() payloadProtocolID} 108 * value set to {@code 0}. These values, if required, can be set through 109 * the appropriate setter method before sending the message. 110 * 111 * @param association 112 * The association to send the message on 113 * 114 * @param address 115 * The preferred peer address of the association to send the message 116 * to, or {@code null} to use the peer primary address 117 * 118 * @param streamNumber 119 * The stream number that the message will be sent on. 120 * 121 * @return The outgoing message info 122 * 123 * @throws IllegalArgumentException 124 * If {@code association} is {@code null}, or the streamNumber is 125 * negative or greater than {@code 65536} 126 */ 127 public static MessageInfo createOutgoing(Association association, 128 SocketAddress address, 129 int streamNumber) { 130 if (association == null) 131 throw new IllegalArgumentException("association cannot be null"); 132 133 if (streamNumber < 0 || streamNumber > 65536) 134 throw new IllegalArgumentException("Invalid stream number"); 135 136 return new sun.nio.ch.sctp.SctpMessageInfoImpl(association, 137 address, streamNumber); 138 } 139 140 /** 141 * Returns the source socket address if the message has been received, 142 * otherwise the preferred destination of the message to be sent. 143 * 144 * @return The socket address, or {@code null} if this instance is to be 145 * used for sending a message and has been construced without 146 * specifying a preferred destination address 147 * 148 */ 149 public abstract SocketAddress address(); 150 151 /** 152 * Returns the association that the message was received on, if the message 153 * has been received, otherwise the association that the message is to be 154 * sent on. 155 * 156 * @return The association, or {@code null} if this instance is to be 157 * used for sending a message and has been construced using the |