channel.write(new NettyElementInfo(),
new InetSocketAddress("255.255.255.255", 9555));
(and replace the broadcast adress of course with your correct
destination address)
@Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
System.out.println(packet.sender().toString());
}
in your handler.
why don't you create new datagram as described in a previous post?
private DatagramPacket getNext(String host, int port) {
DatagramPacket packet = new DatagramPacket(
Unpooled.copiedBuffer("QOTM?", CharsetUtil.UTF_8),
new InetSocketAddress(host, port));
return packet;
}
and then your handler can just write it to wherever you like. This is adapted from the handler for the QOTM (Quote of the Moment):
https://github.com/netty/netty/tree/master/example/src/main/java/io/netty/example
while it's from the client handler, it could just as easily go in your server handler.
-Thufir