diff --git a/src/main/java/org/jboss/netty/channel/socket/sctp/DefaultSctpServerChannelConfig.java b/src/main/java/org/jboss/netty/channel/socket/sctp/DefaultSctpServerChannelConfig.java
new file mode 100644
index 0000000000..13ecf0b924
--- /dev/null
+++ b/src/main/java/org/jboss/netty/channel/socket/sctp/DefaultSctpServerChannelConfig.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package org.jboss.netty.channel.socket.sctp;
+
+import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
+
+import org.jboss.netty.channel.ChannelException;
+import org.jboss.netty.channel.DefaultServerChannelConfig;
+import org.jboss.netty.util.internal.ConversionUtil;
+
+import java.io.IOException;
+
+/**
+ * The default {@link org.jboss.netty.channel.socket.ServerSocketChannelConfig} implementation.
+ *
+ * @author The Netty Project
+ * @author Trustin Lee
+ * @author Jestan Nirojan
+ * @version $Rev$, $Date$
+ */
+public class DefaultSctpServerChannelConfig extends DefaultServerChannelConfig
+ implements SctpServerChannelConfig {
+
+ private final com.sun.nio.sctp.SctpServerChannel serverChannel;
+ private volatile int backlog;
+
+ /**
+ * Creates a new instance.
+ */
+ public DefaultSctpServerChannelConfig(com.sun.nio.sctp.SctpServerChannel serverChannel) {
+ if (serverChannel == null) {
+ throw new NullPointerException("serverChannel");
+ }
+ this.serverChannel = serverChannel;
+ }
+
+ @Override
+ public boolean setOption(String key, Object value) {
+ if (super.setOption(key, value)) {
+ return true;
+ }
+
+ if (key.equals("sctpInitMaxStreams")) {
+ setInitMaxStreams((InitMaxStreams) value);
+ } else if (key.equals("backlog")) {
+ setBacklog(ConversionUtil.toInt(value));
+ } else {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int getSendBufferSize() {
+ try {
+ return serverChannel.getOption(SO_SNDBUF);
+ } catch (IOException e) {
+ throw new ChannelException(e);
+ }
+ }
+
+ @Override
+ public void setSendBufferSize(int sendBufferSize) {
+ try {
+ serverChannel.setOption(SO_SNDBUF, sendBufferSize);
+ } catch (IOException e) {
+ throw new ChannelException(e);
+ }
+ }
+
+ @Override
+ public int getReceiveBufferSize() {
+ try {
+ return serverChannel.getOption(SO_RCVBUF);
+ } catch (IOException e) {
+ throw new ChannelException(e);
+ }
+ }
+
+ @Override
+ public void setReceiveBufferSize(int receiveBufferSize) {
+ try {
+ serverChannel.setOption(SO_RCVBUF, receiveBufferSize);
+ } catch (IOException e) {
+ throw new ChannelException(e);
+ }
+ }
+
+ @Override
+ public InitMaxStreams getInitMaxStreams() {
+ try {
+ return serverChannel.getOption(SCTP_INIT_MAXSTREAMS);
+ } catch (IOException e) {
+ throw new ChannelException(e);
+ }
+ }
+
+ @Override
+ public void setInitMaxStreams(InitMaxStreams initMaxStreams) {
+ try {
+ serverChannel.setOption(SCTP_INIT_MAXSTREAMS, initMaxStreams);
+ } catch (IOException e) {
+ throw new ChannelException(e);
+ }
+ }
+
+ @Override
+ public int getBacklog() {
+ return backlog;
+ }
+
+ @Override
+ public void setBacklog(int backlog) {
+ if (backlog < 0) {
+ throw new IllegalArgumentException("backlog: " + backlog);
+ }
+ this.backlog = backlog;
+ }
+}
diff --git a/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannel.java b/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannel.java
index 376b2bcb04..7eefbb2970 100644
--- a/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannel.java
+++ b/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannel.java
@@ -32,7 +32,7 @@ import java.util.Set;
*/
public interface SctpServerChannel extends ServerChannel {
@Override
- ServerSctpChannelConfig getConfig();
+ SctpServerChannelConfig getConfig();
@Override
InetSocketAddress getLocalAddress();
diff --git a/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannelConfig.java b/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannelConfig.java
index 79f8e293c1..d49fef5cd0 100644
--- a/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannelConfig.java
+++ b/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannelConfig.java
@@ -16,81 +16,80 @@
package org.jboss.netty.channel.socket.sctp;
import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
-import org.jboss.netty.channel.ChannelException;
-import org.jboss.netty.channel.DefaultServerChannelConfig;
-import org.jboss.netty.util.internal.ConversionUtil;
-import java.io.IOException;
+import org.jboss.netty.channel.ChannelConfig;
/**
- * The default {@link org.jboss.netty.channel.socket.ServerSocketChannelConfig} implementation.
+ * A {@link org.jboss.netty.channel.ChannelConfig} for a {@link SctpServerChannelConfig}.
+ *
+ * Available options
+ *
+ * In addition to the options provided by {@link org.jboss.netty.channel.ChannelConfig},
+ * {@link SctpServerChannelConfig} allows the following options in the
+ * option map:
+ *
+ *
+ *
+ * Name | Associated setter method |
+ *
+ * {@code "backlog"} | {@link #setBacklog(int)} |
+ *
+ * * {@code "receiveBufferSize"} | {@link #setReceiveBufferSize(int)} |
+ *
+ * {@code "sendBufferSize"} | {@link #setSendBufferSize(int)} |
+ *
+ * {@code "sctpInitMaxStreams"} | {@link #setInitMaxStreams(InitMaxStreams)} (int)}} |
+ *
+ *
*
* @author The Netty Project
* @author Trustin Lee
* @author Jestan Nirojan
- *
* @version $Rev$, $Date$
*/
-public class SctpServerChannelConfig extends DefaultServerChannelConfig
- implements ServerSctpChannelConfig {
-
- private final com.sun.nio.sctp.SctpServerChannel serverChannel;
- private volatile int backlog;
+public interface SctpServerChannelConfig extends ChannelConfig {
/**
- * Creates a new instance.
+ * Gets the backlog value to specify when the channel binds to a local
+ * address.
*/
- public SctpServerChannelConfig(com.sun.nio.sctp.SctpServerChannel serverChannel) {
- if (serverChannel == null) {
- throw new NullPointerException("serverChannel");
- }
- this.serverChannel = serverChannel;
- }
+ int getBacklog();
- @Override
- public boolean setOption(String key, Object value) {
- if (super.setOption(key, value)) {
- return true;
- }
+ /**
+ * Sets the backlog value to specify when the channel binds to a local
+ * address.
+ */
+ void setBacklog(int backlog);
- if (key.equals("sctpInitMaxStreams")) {
- setInitMaxStreams((InitMaxStreams) value);
- } else if (key.equals("backlog")) {
- setBacklog(ConversionUtil.toInt(value));
- } else {
- return false;
- }
- return true;
- }
- @Override
- public InitMaxStreams getInitMaxStreams() {
- try {
- return serverChannel.getOption(SCTP_INIT_MAXSTREAMS);
- } catch (IOException e) {
- throw new ChannelException(e);
- }
- }
+ /**
+ * Gets the {@code SO_SNDBUF} option.
+ */
+ int getSendBufferSize();
- @Override
- public void setInitMaxStreams(InitMaxStreams initMaxStreams) {
- try {
- serverChannel.setOption(SCTP_INIT_MAXSTREAMS, initMaxStreams);
- } catch (IOException e) {
- throw new ChannelException(e);
- }
- }
+ /**
+ * Sets the {@code SO_SNDBUF} option.
+ */
+ void setSendBufferSize(int sendBufferSize);
- @Override
- public int getBacklog() {
- return backlog;
- }
+ /**
+ * Gets the {@code SO_RCVBUF} option.
+ */
+ int getReceiveBufferSize();
- @Override
- public void setBacklog(int backlog) {
- if (backlog < 0) {
- throw new IllegalArgumentException("backlog: " + backlog);
- }
- this.backlog = backlog;
- }
+ /**
+ * Gets the {@code SO_RCVBUF} option.
+ */
+ void setReceiveBufferSize(int receiveBufferSize);
+
+
+ /**
+ * Gets the {@code SCTP_INIT_MAXSTREAMS} option.
+ */
+ InitMaxStreams getInitMaxStreams();
+
+ /**
+ * Gets the {@code SCTP_INIT_MAXSTREAMS} option.
+ */
+ void setInitMaxStreams(InitMaxStreams initMaxStreams);
}
diff --git a/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannelImpl.java b/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannelImpl.java
index 78ce5e6782..ce902080d4 100644
--- a/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannelImpl.java
+++ b/src/main/java/org/jboss/netty/channel/socket/sctp/SctpServerChannelImpl.java
@@ -16,7 +16,6 @@
package org.jboss.netty.channel.socket.sctp;
import org.jboss.netty.channel.*;
-import org.jboss.netty.channel.socket.ServerSocketChannelConfig;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
@@ -51,7 +50,7 @@ class SctpServerChannelImpl extends AbstractServerChannel
final com.sun.nio.sctp.SctpServerChannel serverChannel;
final Lock shutdownLock = new ReentrantLock();
volatile Selector selector;
- private final ServerSctpChannelConfig config;
+ private final SctpServerChannelConfig config;
private volatile boolean bound;
@@ -82,13 +81,13 @@ class SctpServerChannelImpl extends AbstractServerChannel
throw new ChannelException("Failed to enter non-blocking mode.", e);
}
- config = new SctpServerChannelConfig(serverChannel);
+ config = new DefaultSctpServerChannelConfig(serverChannel);
fireChannelOpen(this);
}
@Override
- public ServerSctpChannelConfig getConfig() {
+ public SctpServerChannelConfig getConfig() {
return config;
}
diff --git a/src/main/java/org/jboss/netty/channel/socket/sctp/ServerSctpChannelConfig.java b/src/main/java/org/jboss/netty/channel/socket/sctp/ServerSctpChannelConfig.java
deleted file mode 100644
index 0cfad45975..0000000000
--- a/src/main/java/org/jboss/netty/channel/socket/sctp/ServerSctpChannelConfig.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version 2.0
- * (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package org.jboss.netty.channel.socket.sctp;
-
-import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
-import org.jboss.netty.channel.ChannelConfig;
-
-/**
- * A {@link org.jboss.netty.channel.ChannelConfig} for a {@link org.jboss.netty.channel.socket.sctp.ServerSctpChannelConfig}.
- *
- * Available options
- *
- * In addition to the options provided by {@link org.jboss.netty.channel.ChannelConfig},
- * {@link org.jboss.netty.channel.socket.sctp.ServerSctpChannelConfig} allows the following options in the
- * option map:
- *
- *
- *
- * Name | Associated setter method |
- *
- * {@code "backlog"} | {@link #setBacklog(int)} |
- *
- * {@code "sctpInitMaxStreams"} | {@link #setInitMaxStreams(InitMaxStreams)} (int)}} |
- *
- *
- *
- * @author The Netty Project
- * @author Trustin Lee
- * @author Jestan Nirojan
- *
- * @version $Rev$, $Date$
- */
-public interface ServerSctpChannelConfig 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 {@code SCTP_INIT_MAXSTREAMS} option.
- */
- InitMaxStreams getInitMaxStreams();
-
- /**
- * Gets the {@code SCTP_INIT_MAXSTREAMS} option.
- */
- void setInitMaxStreams(InitMaxStreams initMaxStreams);
-}
diff --git a/src/main/java/org/jboss/netty/example/sctp/SctpClient.java b/src/main/java/org/jboss/netty/example/sctp/SctpClient.java
index 5a9b988097..bcee3c0210 100644
--- a/src/main/java/org/jboss/netty/example/sctp/SctpClient.java
+++ b/src/main/java/org/jboss/netty/example/sctp/SctpClient.java
@@ -56,6 +56,11 @@ public class SctpClient {
}
});
+ bootstrap.setOption("sendBufferSize", 1048576);
+ bootstrap.setOption("receiveBufferSize", 1048576);
+
+ bootstrap.setOption("sctpNoDelay", true);
+
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress("localhost", 2955), new InetSocketAddress("localhost", 2956));
diff --git a/src/main/java/org/jboss/netty/example/sctp/SctpServer.java b/src/main/java/org/jboss/netty/example/sctp/SctpServer.java
index 6f8dda1975..951b486789 100644
--- a/src/main/java/org/jboss/netty/example/sctp/SctpServer.java
+++ b/src/main/java/org/jboss/netty/example/sctp/SctpServer.java
@@ -53,6 +53,10 @@ public class SctpServer {
return Channels.pipeline(executionHandler, new SctpServerHandler());
}
});
+ bootstrap.setOption("sendBufferSize", 1048576);
+ bootstrap.setOption("receiveBufferSize", 1048576);
+
+ bootstrap.setOption("child.sctpNoDelay", true);
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress("localhost", 2955));