--- experimental/server/XMLReader/XMLSender.java 2000/11/08 08:33:36 1.1 +++ experimental/server/XMLReader/XMLSender.java 2000/11/17 15:04:05 1.4 @@ -7,25 +7,33 @@ import java.util.*; public class XMLSender { public static void main(String[] args) throws IOException { - if (args.length != 1) { - System.out.println("Usage: java QuoteClient "); - return; + if (args.length != 2) { + System.out.println("Usage: java XMLSender "); + System.exit(0); } + int port = 4589; + // stuff to send - String text = new String("This is my message - hello!"); + BufferedReader br = new BufferedReader(new FileReader(args[1])); + String xml = ""; + String line = br.readLine(); + while (line != null){ + xml += line; + line = br.readLine(); + } // get a datagram socket DatagramSocket socket = new DatagramSocket(); // send request - byte[] buf = text.getBytes(); + byte[] buf = xml.getBytes(); InetAddress address = InetAddress.getByName(args[0]); - DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4589); + DatagramPacket packet = new DatagramPacket(buf, buf.length, address, port); socket.send(packet); String dataOut = new String(packet.getData()); - System.out.println("Sending: " + dataOut); + System.out.println("Sending the following: " + dataOut); socket.close(); }