JavaDoc for channel.socket package

This commit is contained in:
Trustin Lee 2008-09-03 05:13:47 +00:00
parent bb5c59e816
commit 54e81bde72
8 changed files with 154 additions and 0 deletions

View File

@ -26,6 +26,8 @@ import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelPipeline;
/**
* A {@link ChannelFactory} which creates a client-side {@link SocketChannel}.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*

View File

@ -31,12 +31,23 @@ import org.jboss.netty.channel.ChannelException;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.util.ConversionUtil;
/**
* The default {@link ServerSocketChannelConfig} implementation.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*
* @version $Rev$, $Date$
*/
public class DefaultServerSocketChannelConfig implements ServerSocketChannelConfig {
private final ServerSocket socket;
private volatile int backlog;
private volatile ChannelPipelineFactory pipelineFactory;
/**
* Creates a new instance.
*/
public DefaultServerSocketChannelConfig(ServerSocket socket) {
if (socket == null) {
throw new NullPointerException("socket");
@ -50,6 +61,10 @@ public class DefaultServerSocketChannelConfig implements ServerSocketChannelConf
}
}
/**
* Sets an individual option. You can override this method to support
* additional configuration parameters.
*/
protected boolean setOption(String key, Object value) {
if (key.equals("receiveBufferSize")) {
setReceiveBufferSize(ConversionUtil.toInt(value));

View File

@ -31,11 +31,23 @@ import org.jboss.netty.channel.ChannelException;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.util.ConversionUtil;
/**
* The default {@link SocketChannelConfig} implementation.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*
* @version $Rev$, $Date$
*
*/
public class DefaultSocketChannelConfig implements SocketChannelConfig {
private final Socket socket;
private volatile int connectTimeoutMillis = 10000; // 10 seconds
/**
* Creates a new instance.
*/
public DefaultSocketChannelConfig(Socket socket) {
if (socket == null) {
throw new NullPointerException("socket");
@ -49,6 +61,10 @@ public class DefaultSocketChannelConfig implements SocketChannelConfig {
}
}
/**
* Sets an individual option. You can override this method to support
* additional configuration parameters.
*/
protected boolean setOption(String key, Object value) {
if (key.equals("receiveBufferSize")) {
setReceiveBufferSize(ConversionUtil.toInt(value));

View File

@ -27,6 +27,9 @@ import java.net.InetSocketAddress;
import org.jboss.netty.channel.Channel;
/**
* A server-side TCP/IP socket {@link Channel} which accepts incoming TCP/IP
* connections.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*

View File

@ -22,14 +22,55 @@
*/
package org.jboss.netty.channel.socket;
import java.net.ServerSocket;
import org.jboss.netty.channel.ChannelConfig;
/**
* A {@link ChannelConfig} for a {@link ServerSocketChannel}.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*
* @version $Rev$, $Date$
*/
public interface ServerSocketChannelConfig extends ChannelConfig {
/**
* Gets the backlog value to specify when the channel binds to a local
* address.
*/
int getBacklog();
/**
* Sets the backlog value to specify when the channel binds to a local
* address.
*/
void setBacklog(int backlog);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
*/
boolean isReuseAddress();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
*/
void setReuseAddress(boolean reuseAddress);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
*/
int getReceiveBufferSize();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
*/
void setReceiveBufferSize(int receiveBufferSize);
/**
* Sets the performance preferences as specified in
* {@link ServerSocket#setPerformancePreferences(int, int, int)}.
*/
void setPerformancePreferences(int connectionTime, int latency, int bandwidth);
}

View File

@ -26,6 +26,8 @@ import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelPipeline;
/**
* A {@link ChannelFactory} which creates a {@link ServerSocketChannel}.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*

View File

@ -27,6 +27,9 @@ import java.net.InetSocketAddress;
import org.jboss.netty.channel.Channel;
/**
* A TCP/IP socket {@link Channel} which was either accepted by
* {@link ServerSocketChannel} or created by {@link ClientSocketChannelFactory}.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*

View File

@ -22,23 +22,95 @@
*/
package org.jboss.netty.channel.socket;
import java.net.Socket;
import org.jboss.netty.channel.ChannelConfig;
/**
* A {@link ChannelConfig} for a {@link SocketChannel}.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*
* @version $Rev$, $Date$
*
*/
public interface SocketChannelConfig extends ChannelConfig {
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_TCPNODELAY}</a> option.
*/
boolean isTcpNoDelay();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_TCPNODELAY}</a> option.
*/
void setTcpNoDelay(boolean tcpNoDelay);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_LINGER}</a> option.
*/
int getSoLinger();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_LINGER}</a> option.
*/
void setSoLinger(int soLinger);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_SNDBUF}</a> option.
*/
int getSendBufferSize();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_SNDBUF}</a> option.
*/
void setSendBufferSize(int sendBufferSize);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
*/
int getReceiveBufferSize();
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
*/
void setReceiveBufferSize(int receiveBufferSize);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_KEEPALIVE}</a> option.
*/
boolean isKeepAlive();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_KEEPALIVE}</a> option.
*/
void setKeepAlive(boolean keepAlive);
/**
* Gets the traffic class.
*/
int getTrafficClass();
/**
* Sets the traffic class as specified in {@link Socket#setTrafficClass(int)}.
*/
void setTrafficClass(int trafficClass);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
*/
boolean isReuseAddress();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
*/
void setReuseAddress(boolean reuseAddress);
/**
* Sets the performance preferences as specified in
* {@link Socket#setPerformancePreferences(int, int, int)}.
*/
void setPerformancePreferences(
int connectionTime, int latency, int bandwidth);
}