Skip to content

Instantly share code, notes, and snippets.

@crised
Created June 16, 2014 12:41
Show Gist options
  • Save crised/9df08d48ae861833b9a4 to your computer and use it in GitHub Desktop.
Save crised/9df08d48ae861833b9a4 to your computer and use it in GitHub Desktop.
public class OutboundHandler extends ChannelOutboundHandlerAdapter{
@Override
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
System.out.println("Bind happened");
System.out.println(localAddress);
InetSocketAddress ipSocketAddress = new InetSocketAddress("255.255.255.255", 7686);
ByteBuf byteBuf = Unpooled.copiedBuffer("QOTM?", CharsetUtil.UTF_8);
DatagramPacket udpPacket = new DatagramPacket(byteBuf, ipSocketAddress);
ctx.write(udpPacket);
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
System.out.println("Write is never called!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment