A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
The EchoUDPClient class is a UDP implementation of a client for the Echo protocol described in RFC 862. To use the class, just open a local UDP port with {@link org.apache.commons.net.DatagramSocketClient#open open }and call {@link #send send } to send datagrams to the server, then call {@link #rece...
}
}
private static void sendUdpString(final String payload, final String host, final int port) throws UnknownHostException, IOException
{
final EchoUDPClient client = new EchoUDPClient();
client.open();
try
{
final byte[] writeBuffer = payload.getBytes();
client.setSoTimeout(3000);
client.send(writeBuffer, writeBuffer.length, InetAddress.getByName(host), port);
}
finally
{
client.close();
}
}
}
return config;
}
private void sendUdpString(final String payload, final String host, final int port) throws UnknownHostException, IOException
{
final EchoUDPClient client = new EchoUDPClient();
client.open();
try
{
final byte[] writeBuffer = payload.getBytes();
client.setSoTimeout(3000);
client.send(writeBuffer, writeBuffer.length, InetAddress.getByName(host), port);
}
finally
{
client.close();
}
}
}
InetAddress address;
EchoUDPClient client;
input = new BufferedReader(new InputStreamReader(System.in));
address = InetAddress.getByName(host);
client = new EchoUDPClient();
client.open();
// If we don't receive an echo within 5 seconds, assume the packet is lost.
client.setSoTimeout(5000);
System.out.println("Ready to echo to " + host + ".");