@Override protected int peek(InetAddress sender) throws IOException { // We don't actually want the data: we just want the DatagramPacket's filled-in address. DatagramPacket packet = new DatagramPacket(EmptyArray.BYTE, 0); int result = peekData(packet); // Note: evil side-effect on InetAddress! This method should have returned InetSocketAddress! sender.ipaddress = packet.getAddress().getAddress(); return result; }
@Override public void send(DatagramPacket packet) throws IOException { int port = isNativeConnected ? 0 : packet.getPort(); InetAddress address = isNativeConnected ? null : packet.getAddress(); IoBridge.sendto(fd, packet.getData(), packet.getOffset(), packet.getLength(), 0, address, port); }