Java tutorial
import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; public class Main { private final static int BUFSIZE = 20; public static void main(String args[]) { try { int port = 80; DatagramSocket ds = new DatagramSocket(port); while (true) { byte buffer[] = new byte[BUFSIZE]; DatagramPacket dp = new DatagramPacket(buffer, buffer.length, InetAddress.getByName("google.com"), 8080); ds.receive(dp); String str = new String(dp.getData()); System.out.println(str); } } catch (Exception e) { e.printStackTrace(); } } }