DatagramExample -- sending and receiving datagram
packets.
The DatagramExample class sets up a server socket
that listens for datagrams. The partner DatagramClient
class sends datagrams.
To see this example in action:
- Compile the Java source file, DatagramExample.java:
javac DatagramExample.java
- Run the class on one machine:
java DatagramExample
- On a separate machine, or in a separate command line window,
run the client class as a separate program. The final
argument, if present, should name the machine on which
your server process is running (the default value is the local
host):
java DatagramClient [server-host-machine]
The source.