jdk/src/share/classes/sun/nio/ch/SocketOpts.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2001 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.nio.ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.nio.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.net.NetworkInterface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
// Typical use:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
//     sc.options()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
//         .noDelay(true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
//         .typeOfService(SocketOpts.IP.TOS_RELIABILITY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
//         .sendBufferSize(1024)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
//         .receiveBufferSize(1024)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
//         .keepAlive(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
public interface SocketOpts {   // SocketOptions already used in java.net
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    // Options that apply to all kinds of sockets
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    // SO_BROADCAST
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    public abstract boolean broadcast() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public abstract SocketOpts broadcast(boolean b) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    // SO_KEEPALIVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public abstract boolean keepAlive() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public abstract SocketOpts keepAlive(boolean b) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    // SO_LINGER
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public abstract int linger() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    public abstract SocketOpts linger(int n) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    // SO_OOBINLINE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public abstract boolean outOfBandInline() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public abstract SocketOpts outOfBandInline(boolean b) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    // SO_RCVBUF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public abstract int receiveBufferSize() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public abstract SocketOpts receiveBufferSize(int n) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // SO_SNDBUF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public abstract int sendBufferSize() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public abstract SocketOpts sendBufferSize(int n) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // SO_REUSEADDR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public abstract boolean reuseAddress() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public abstract SocketOpts reuseAddress(boolean b) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    // IP-specific options
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public static interface IP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        extends SocketOpts
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        // IP_MULTICAST_IF2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        public abstract NetworkInterface multicastInterface()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        public abstract IP multicastInterface(NetworkInterface ni)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        // IP_MULTICAST_LOOP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        public abstract boolean multicastLoop() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        public abstract IP multicastLoop(boolean b) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        // IP_TOS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        public static final int TOS_LOWDELAY = 0x10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        public static final int TOS_THROUGHPUT = 0x08;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        public static final int TOS_RELIABILITY = 0x04;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        public static final int TOS_MINCOST = 0x02;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        public abstract int typeOfService() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        public abstract IP typeOfService(int tos) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        // TCP-specific options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        public static interface TCP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            extends IP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            // TCP_NODELAY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            public abstract boolean noDelay() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            public abstract TCP noDelay(boolean b) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
}