1 /* 2 * Copyright 2012 The Netty Project 3 * 4 * The Netty Project licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the License. You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 package io.netty.channel.socket; 17 18 import io.netty.buffer.ByteBufAllocator; 19 import io.netty.channel.ChannelConfig; 20 import io.netty.channel.MessageSizeEstimator; 21 import io.netty.channel.RecvByteBufAllocator; 22 23 import java.net.ServerSocket; 24 import java.net.StandardSocketOptions; 25 26 /** 27 * A {@link ChannelConfig} for a {@link ServerSocketChannel}. 28 * 29 * <h3>Available options</h3> 30 * 31 * In addition to the options provided by {@link ChannelConfig}, 32 * {@link ServerSocketChannelConfig} allows the following options in the 33 * option map: 34 * 35 * <table border="1" cellspacing="0" cellpadding="6"> 36 * <tr> 37 * <th>Name</th><th>Associated setter method</th> 38 * </tr><tr> 39 * <td>{@code "backlog"}</td><td>{@link #setBacklog(int)}</td> 40 * </tr><tr> 41 * <td>{@code "reuseAddress"}</td><td>{@link #setReuseAddress(boolean)}</td> 42 * </tr><tr> 43 * <td>{@code "receiveBufferSize"}</td><td>{@link #setReceiveBufferSize(int)}</td> 44 * </tr> 45 * </table> 46 */ 47 public interface ServerSocketChannelConfig extends ChannelConfig { 48 49 /** 50 * Gets the backlog value to specify when the channel binds to a local 51 * address. 52 */ 53 int getBacklog(); 54 55 /** 56 * Sets the backlog value to specify when the channel binds to a local 57 * address. 58 */ 59 ServerSocketChannelConfig setBacklog(int backlog); 60 61 /** 62 * Gets the {@link StandardSocketOptions#SO_REUSEADDR} option. 63 */ 64 boolean isReuseAddress(); 65 66 /** 67 * Sets the {@link StandardSocketOptions#SO_REUSEADDR} option. 68 */ 69 ServerSocketChannelConfig setReuseAddress(boolean reuseAddress); 70 71 /** 72 * Gets the {@link StandardSocketOptions#SO_RCVBUF} option. 73 */ 74 int getReceiveBufferSize(); 75 76 /** 77 * Gets the {@link StandardSocketOptions#SO_SNDBUF} option. 78 */ 79 ServerSocketChannelConfig setReceiveBufferSize(int receiveBufferSize); 80 81 /** 82 * Sets the performance preferences as specified in 83 * {@link ServerSocket#setPerformancePreferences(int, int, int)}. 84 */ 85 ServerSocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth); 86 87 @Override 88 ServerSocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis); 89 90 @Override 91 ServerSocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead); 92 93 @Override 94 ServerSocketChannelConfig setWriteSpinCount(int writeSpinCount); 95 96 @Override 97 ServerSocketChannelConfig setAllocator(ByteBufAllocator allocator); 98 99 @Override 100 ServerSocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator); 101 102 @Override 103 ServerSocketChannelConfig setAutoRead(boolean autoRead); 104 105 @Override 106 ServerSocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator); 107 }