ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/XMLReader/XMLSender.java
(Generate patch)

Comparing experimental/server/XMLReader/XMLSender.java (file contents):
Revision 1.1 by pjm2, Wed Nov 8 08:33:36 2000 UTC vs.
Revision 1.2 by pjm2, Fri Nov 17 12:16:39 2000 UTC

# Line 7 | Line 7 | import java.util.*;
7   public class XMLSender {
8      public static void main(String[] args) throws IOException {
9  
10 <        if (args.length != 1) {
11 <             System.out.println("Usage: java QuoteClient <hostname>");
12 <             return;
10 >        if (args.length != 2) {
11 >             System.out.println("Usage: java XMLSender <hostname> <filename.xml>");
12          }
13          
14 +        int port = 4589;
15 +        
16              // stuff to send
17 <        String text = new String("This is my message - hello!");
17 >        BufferedReader br = new BufferedReader(new FileReader(args[1]));
18 >        String xml = "";
19 >        String line = br.readLine();
20 >        xml += line;
21 >        while (line != null){
22 >            line = br.readLine();
23 >            xml += line;
24 >        }
25  
26              // get a datagram socket
27          DatagramSocket socket = new DatagramSocket();
28  
29              // send request
30 <        byte[] buf = text.getBytes();
30 >        byte[] buf = xml.getBytes();
31          InetAddress address = InetAddress.getByName(args[0]);
32 <        DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4589);
32 >        DatagramPacket packet = new DatagramPacket(buf, buf.length, address, port);
33          socket.send(packet);
34  
35          String dataOut = new String(packet.getData());
36 <        System.out.println("Sending: " + dataOut);
36 >        System.out.println("Sending the following: " + dataOut);
37      
38          socket.close();
39      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines