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.api;
21
22 import java.net.DatagramSocket;
23 import java.net.Socket;
24
25 import org.apache.mina.session.TrafficClassEnum;
26
27 /**
28 * The configuration of {@link IoSession}.
29 *
30 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
31 */
32 public interface IoSessionConfig {
33
34 /**
35 * Returns the size of the read buffer that I/O processor allocates
36 * per each read. It's unusual to adjust this property because
37 * it's often adjusted automatically by the I/O processor.
38 *
39 * @return The buffer size, or null if its not set
40 */
41 Integer getReadBufferSize();
42
43 /**
44 * Sets the size of the read buffer that I/O processor allocates
45 * per each read. It's unusual to adjust this property because
46 * it's often adjusted automatically by the I/O processor.
47 *
48 * @param readBufferSize The buffer size used to read data from the socket
49 */
50 void setReadBufferSize(int readBufferSize);
51
52 /**
53 * @see DatagramSocket#getSendBufferSize()
54 */
55 Integer getSendBufferSize();
56
57 /**
58 * Sets the size of the buffer that I/O processor allocates
59 * per each write. It's unusual to adjust this property because
60 * it's often adjusted automatically by the I/O processor.
61 *
62 * @param sendBufferSize The buffer size used to send data into the socket
63 */
64 void setSendBufferSize(int sendBufferSize);
65
66 /**
67 * Returns idle time for the specified type of idleness in milli-seconds.
68 * @see IdleStatus
69 * @return the idle time in ms or <code>-1</code> if no idle time configured for this status
70 */
71 long getIdleTimeInMillis(IdleStatus status);
72
73 /**
74 * Set the delay before an {@link IoSession} is considered idle for a given
75 * operation type (read/write/both) @see IdleStatus
76 *
77 * @param status the type of idle (read/write/both) timeout to set
78 * @param ildeTimeInMilli the timeout in milliseconds (<code>-1</code> for no idle detection on this status)
79 */
80 void setIdleTimeInMillis(IdleStatus status, long ildeTimeInMilli);
81
82 /**
83 * @see Socket#getTrafficClass()
84 * @return The ToS set for this session
85 */
86 int getTrafficClass();
87
88 /**
89 * Set the ToS flag for this session
90 * @see Socket#setTrafficClass(int)
91 * @param trafficClass The ToS to set
92 */
93 void setTrafficClass(TrafficClassEnum trafficClass);
94
95 /**
96 * Set the ToS flag for this session
97 * @see Socket#setTrafficClass(int)
98 * @param trafficClass The ToS to set
99 */
100 void setTrafficClass(int trafficClass);
101
102 /**
103 * @see Socket#getReuseAddress()
104 */
105 Boolean isReuseAddress();
106
107 /**
108 * @see Socket#setReuseAddress(boolean)
109 * @see DatagramSocket#setReuseAddress(boolean)
110 * return <code>null</code> if the default system value is used
111 */
112 void setReuseAddress(boolean reuseAddress);
113
114 /**
115 * Get the SO_TIMEOUT set for this socket
116 * @see Socket#getSoTimeout()
117 * @see DatagramSocket#getSoTimeout()
118 *
119 * @return The Timeout, in milliseconds. 0 means infinite.
120 */
121 Integer getTimeout();
122
123 /**
124 * Sets the SO_TIMEOUT option for this socket
125 * @see Socket#setSoTimeout(int)
126 * @see DatagramSocket#setSoTimeout(int)
127 * @param timeOut The timeout to set, in milliseconds. 0 means infinite
128 */
129 void setTimeout(int timeOut);
130 }