View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   *
19   */
20  package org.apache.mina.transport.socket;
21  
22  import java.net.DatagramSocket;
23  import java.net.PortUnreachableException;
24  
25  import org.apache.mina.core.session.IoSessionConfig;
26  
27  /**
28   * An {@link IoSessionConfig} for datagram transport type.
29   *
30   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
31   */
32  public interface DatagramSessionConfig extends IoSessionConfig {
33      /**
34       * @see DatagramSocket#getBroadcast()
35       * 
36       * @return <tt>true</tt> if SO_BROADCAST is enabled.
37       */
38      boolean isBroadcast();
39  
40      /**
41       * @see DatagramSocket#setBroadcast(boolean)
42       * 
43       * @param broadcast Tells if SO_BROACAST is enabled or not 
44       */
45      void setBroadcast(boolean broadcast);
46  
47      /**
48       * @see DatagramSocket#getReuseAddress()
49       * 
50       * @return <tt>true</tt> if SO_REUSEADDR is enabled.
51       */
52      boolean isReuseAddress();
53  
54      /**
55       * @see DatagramSocket#setReuseAddress(boolean)
56       * 
57       * @param reuseAddress Tells if SO_REUSEADDR is enabled or disabled
58       */
59      void setReuseAddress(boolean reuseAddress);
60  
61      /**
62       * @see DatagramSocket#getReceiveBufferSize()
63       * 
64       * @return the size of the receive buffer
65       */
66      int getReceiveBufferSize();
67  
68      /**
69       * @see DatagramSocket#setReceiveBufferSize(int)
70       * 
71       * @param receiveBufferSize The size of the receive buffer
72       */
73      void setReceiveBufferSize(int receiveBufferSize);
74  
75      /**
76       * @see DatagramSocket#getSendBufferSize()
77       * 
78       * @return the size of the send buffer
79       */
80      int getSendBufferSize();
81  
82      /**
83       * @see DatagramSocket#setSendBufferSize(int)
84       * 
85       * @param sendBufferSize The size of the send buffer
86       */
87      void setSendBufferSize(int sendBufferSize);
88  
89      /**
90       * @see DatagramSocket#getTrafficClass()
91       * 
92       * @return the traffic class
93       */
94      int getTrafficClass();
95  
96      /**
97       * @see DatagramSocket#setTrafficClass(int)
98       * 
99       * @param trafficClass The traffic class to set, one of IPTOS_LOWCOST (0x02)
100      * IPTOS_RELIABILITY (0x04), IPTOS_THROUGHPUT (0x08) or IPTOS_LOWDELAY (0x10)
101      */
102     void setTrafficClass(int trafficClass);
103 
104     /**
105      * If method returns true, it means session should be closed when a
106      * {@link PortUnreachableException} occurs.
107      * 
108      * @return Tells if we should close if the port is unreachable
109      */
110     boolean isCloseOnPortUnreachable();
111 
112     /**
113      * Sets if the session should be closed if an {@link PortUnreachableException} 
114      * occurs.
115      * 
116      * @param closeOnPortUnreachable <tt>true</tt> if we should close if the port is unreachable
117      */
118     void setCloseOnPortUnreachable(boolean closeOnPortUnreachable);
119 }