Created
September 24, 2013 21:10
-
-
Save codingtony/6691297 to your computer and use it in GitHub Desktop.
Example to add a ChannelFutureListener to trap the BindException in Netty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
final int port=8888; | |
ServerBootstrap b = new ServerBootstrap(); | |
//... | |
b.bind(port).addListener(new ChannelFutureListener() { | |
@Override | |
public void operationComplete(ChannelFuture future) throws Exception { | |
if (!future.isSuccess()) { | |
if (future.cause() instanceof BindException) { | |
System.err.println("Bind Exception on port : " + port); | |
} | |
} | |
} | |
}).sync().channel().closeFuture().sync(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment