import java.io.*;
import java.net.*;
import java.util.*;

public class BODetect {
    public static void main(String[] args) throws IOException {

        // get a datagram socket
        DatagramSocket socket = new DatagramSocket();

        // send request
        byte[] buf = new byte[256];
        String hello = "Hello how re you?";
        buf = hello.getBytes();
        
        InetAddress address = InetAddress.getByName(args[0]);
        DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 37);
        socket.send(packet);
        System.out.println("packet sent to "+address);

        // get response
        byte[] rbuf = new byte[256];
        packet = new DatagramPacket(rbuf, rbuf.length);
        socket.receive(packet);

        // display response
        String received = new String(packet.getData());
        System.out.println("From server : " + received);

        socket.close();
    }
}
