// UDP Client that reads a line of text, sends it to a server listening
// on the same machine at port 9876, and capitalizes it

import java.io.*;
import java.net.*;
class UDPClient 
{
	public static void main(String argv[]) throws Exception
	{
		String sentence;
		String modifiedSentence;
		BufferedReader inFromUser = new BufferedReader(
			new InputStreamReader(System.in));
		DatagramSocket clientSocket = new DatagramSocket();
		InetAddress IPAddress = InetAddress.getByName("localhost");
		byte[] sendData = new byte[1024];
		byte[] receiveData = new byte[1024];

		sentence = inFromUser.readLine();
		sendData = sentence.getBytes();
		DatagramPacket sendPacket = new DatagramPacket(sendData,
			 sendData.length,IPAddress, 9876);
		clientSocket.send(sendPacket);
		DatagramPacket receivePacket = new DatagramPacket(
			receiveData, receiveData.length);
		clientSocket.receive(receivePacket);
		modifiedSentence = new String(receivePacket.getData());
		System.out.println("From Server: " + modifiedSentence);
		clientSocket.close();
	}
}
