Add more convenience methods to Bootstrap and ServerBootstrap
This commit is contained in:
parent
34f697a06c
commit
53f16ce003
@ -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());
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user