1 /* 2 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package com.sun.nio.sctp; 26 27 /** 28 * A class that represents an SCTP association. 29 * 30 * <P> An association exists between two SCTP endpoints. Each endpoint is 31 * represented by a list of transport addresses through which that endpoint can 32 * be reached and from which it will originate SCTP messages. The association 33 * spans over all of the possible source/destination combinations which may be 34 * generated from each endpoint's lists of addresses. 35 * 36 * <P> Associations are identified by their Association ID. 37 * Association ID's are guaranteed to be unique for the lifetime of the 38 * association. An association ID may be reused after the association has been 39 * shutdown. An association ID is not unique across multiple SCTP channels. 40 * An Association's local and remote addresses may change if the SCTP 41 * implementation supports <I>Dynamic Address Reconfiguration</I> as defined by 42 * <A HREF="http://tools.ietf.org/html/rfc5061">RFC5061</A>, see the 43 * {@code bindAddress} and {@code unbindAddress} methods of {@link SctpChannel}, 44 * {@link SctpServerChannel}, and {@link SctpMultiChannel}. 45 * 46 * <P> An {@code Association} is returned from an {@link 47 * SctpChannel#association SctpChannel} or an {@link 48 * SctpMultiChannel#associations SctpMultiChannel}, as well 49 * as being given as a parameter to {@link NotificationHandler 50 * NotificationHandler} methods. 51 * 52 * @since 1.7 53 */ 54 public class Association { 55 private final int associationID; 56 private final int maxInStreams; 57 private final int maxOutStreams; 58 59 /** 60 * Initializes a new instance of this class. 61 * 62 * @param associationID 63 * The association ID 64 * @param maxInStreams 65 * The maximum number of inbound streams 66 * @param maxOutStreams 67 * The maximum number of outbound streams 68 */ Association(int associationID, int maxInStreams, int maxOutStreams)69 protected Association(int associationID, 70 int maxInStreams, 71 int maxOutStreams) { 72 this.associationID = associationID; 73 this.maxInStreams = maxInStreams; 74 this.maxOutStreams = maxOutStreams; 75 } 76 77 /** 78 * Returns the associationID. 79 * 80 * @return The association ID 81 */ associationID()82 public final int associationID() { 83 return associationID; 84 }; 85 86 /** 87 * Returns the maximum number of inbound streams that this association 88 * supports. 89 * 90 * <P> Data received on this association will be on stream number 91 * {@code s}, where {@code 0 <= s < maxInboundStreams()}. 92 * 93 * @return The maximum number of inbound streams 94 */ maxInboundStreams()95 public final int maxInboundStreams() { 96 return maxInStreams; 97 }; 98 99 /** 100 * Returns the maximum number of outbound streams that this association 101 * supports. 102 * 103 * <P> Data sent on this association must be on stream number 104 * {@code s}, where {@code 0 <= s < maxOutboundStreams()}. 105 * 106 * @return The maximum number of outbound streams 107 */ maxOutboundStreams()108 public final int maxOutboundStreams() { 109 return maxOutStreams; 110 }; 111 } 112