You are on page 1of 1

packageaula0;

importjava.io.*;
importjava.net.*;
publicclassUdpClient{

publicstaticvoidmain(String[]args)throwsException{

finalintport=9000;
finalInetAddressaddress=
InetAddress.getByName(args[0]);

DatagramSocketsocket=newDatagramSocket();
Stringinput;
do{
input=readLine()+"\n";
DatagramPacketpacket=new
DatagramPacket(input.getBytes(),input.getBytes().length);
packet.setAddress(address);
packet.setPort(port);
socket.send(packet);
}while(!input.equals(".\n"));

socket.close();
}

publicstaticStringreadLine()throwsException{
returnnewBufferedReader(new
InputStreamReader(System.in)).readLine();
}
}

You might also like