Add more convenience methods to Bootstrap and ServerBootstrap

This commit is contained in:
Trustin Lee 2012-05-30 23:47:15 -07:00
parent 34f697a06c
commit 53f16ce003
2 changed files with 17 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import io.netty.channel.EventLoop;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.channels.ClosedChannelException;
@ -85,6 +86,11 @@ public class Bootstrap {
return this;
}
public Bootstrap localAddress(InetAddress host, int port) {
localAddress = new InetSocketAddress(host, port);
return this;
}
public Bootstrap remoteAddress(SocketAddress remoteAddress) {
this.remoteAddress = remoteAddress;
return this;
@ -95,6 +101,11 @@ public class Bootstrap {
return this;
}
public Bootstrap remoteAddress(InetAddress host, int port) {
remoteAddress = new InetSocketAddress(host, port);
return this;
}
public ChannelFuture bind() {
validate();
return bind(channel.newFuture());

View File

@ -17,6 +17,7 @@ import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.SocketAddresses;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.channels.ClosedChannelException;
@ -124,6 +125,11 @@ public class ServerBootstrap {
return this;
}
public ServerBootstrap localAddress(InetAddress host, int port) {
localAddress = new InetSocketAddress(host, port);
return this;
}
public ChannelFuture bind() {
validate();
return bind(channel.newFuture());