UDP Server and Client in Java

Simple UDP server and client program in Java.
In this program Server sends message to client.
First, run the Client and then run the server.

UDP Server

Message can be sent to any system in LAN.
If you wish to do, Uncomment the 9th line and change the the 'mypc' to destination pc name, then remove the 8th line.

  1. span style="color: #006699;">java.net.*java.io.*java.util.*//InetAddress host = InetAddress.getByName("MYPC");
  2. "Hello! This msg is sent from UDP Server \n"

UDP Client

  1. span style="color: #006699;">java.net.*java.io.*