2
|
1 |
/*
|
|
2 |
* Copyright 2001 Sun Microsystems, Inc. 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. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package sun.nio.ch;
|
|
27 |
|
|
28 |
import java.io.IOException;
|
|
29 |
import java.nio.*;
|
|
30 |
import java.net.NetworkInterface;
|
|
31 |
|
|
32 |
|
|
33 |
// Typical use:
|
|
34 |
//
|
|
35 |
// sc.options()
|
|
36 |
// .noDelay(true)
|
|
37 |
// .typeOfService(SocketOpts.IP.TOS_RELIABILITY)
|
|
38 |
// .sendBufferSize(1024)
|
|
39 |
// .receiveBufferSize(1024)
|
|
40 |
// .keepAlive(true);
|
|
41 |
//
|
|
42 |
|
|
43 |
|
|
44 |
public interface SocketOpts { // SocketOptions already used in java.net
|
|
45 |
|
|
46 |
// Options that apply to all kinds of sockets
|
|
47 |
|
|
48 |
// SO_BROADCAST
|
|
49 |
public abstract boolean broadcast() throws IOException;
|
|
50 |
public abstract SocketOpts broadcast(boolean b) throws IOException;
|
|
51 |
|
|
52 |
// SO_KEEPALIVE
|
|
53 |
public abstract boolean keepAlive() throws IOException;
|
|
54 |
public abstract SocketOpts keepAlive(boolean b) throws IOException;
|
|
55 |
|
|
56 |
// SO_LINGER
|
|
57 |
public abstract int linger() throws IOException;
|
|
58 |
public abstract SocketOpts linger(int n) throws IOException;
|
|
59 |
|
|
60 |
// SO_OOBINLINE
|
|
61 |
public abstract boolean outOfBandInline() throws IOException;
|
|
62 |
public abstract SocketOpts outOfBandInline(boolean b) throws IOException;
|
|
63 |
|
|
64 |
// SO_RCVBUF
|
|
65 |
public abstract int receiveBufferSize() throws IOException;
|
|
66 |
public abstract SocketOpts receiveBufferSize(int n) throws IOException;
|
|
67 |
|
|
68 |
// SO_SNDBUF
|
|
69 |
public abstract int sendBufferSize() throws IOException;
|
|
70 |
public abstract SocketOpts sendBufferSize(int n) throws IOException;
|
|
71 |
|
|
72 |
// SO_REUSEADDR
|
|
73 |
public abstract boolean reuseAddress() throws IOException;
|
|
74 |
public abstract SocketOpts reuseAddress(boolean b) throws IOException;
|
|
75 |
|
|
76 |
|
|
77 |
// IP-specific options
|
|
78 |
|
|
79 |
public static interface IP
|
|
80 |
extends SocketOpts
|
|
81 |
{
|
|
82 |
|
|
83 |
// IP_MULTICAST_IF2
|
|
84 |
public abstract NetworkInterface multicastInterface()
|
|
85 |
throws IOException;
|
|
86 |
public abstract IP multicastInterface(NetworkInterface ni)
|
|
87 |
throws IOException;
|
|
88 |
|
|
89 |
// IP_MULTICAST_LOOP
|
|
90 |
public abstract boolean multicastLoop() throws IOException;
|
|
91 |
public abstract IP multicastLoop(boolean b) throws IOException;
|
|
92 |
|
|
93 |
// IP_TOS
|
|
94 |
public static final int TOS_LOWDELAY = 0x10;
|
|
95 |
public static final int TOS_THROUGHPUT = 0x08;
|
|
96 |
public static final int TOS_RELIABILITY = 0x04;
|
|
97 |
public static final int TOS_MINCOST = 0x02;
|
|
98 |
public abstract int typeOfService() throws IOException;
|
|
99 |
public abstract IP typeOfService(int tos) throws IOException;
|
|
100 |
|
|
101 |
|
|
102 |
// TCP-specific options
|
|
103 |
|
|
104 |
public static interface TCP
|
|
105 |
extends IP
|
|
106 |
{
|
|
107 |
// TCP_NODELAY
|
|
108 |
public abstract boolean noDelay() throws IOException;
|
|
109 |
public abstract TCP noDelay(boolean b) throws IOException;
|
|
110 |
|
|
111 |
}
|
|
112 |
|
|
113 |
}
|
|
114 |
|
|
115 |
}
|