ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/XMLReader/XMLSender.java
Revision: 1.1
Committed: Wed Nov 8 08:33:36 2000 UTC (24 years ago) by pjm2
Branch: MAIN
Log Message:
First CVSing of Paul's XML/UDP reading stuff.  WORK IN PROGRESS.

File Contents

# User Rev Content
1 pjm2 1.1 import java.io.*;
2     import java.net.*;
3     import java.util.*;
4    
5     // Class used to send arbitrary crap to the XMLReader
6    
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;
13     }
14    
15     // stuff to send
16     String text = new String("This is my message - hello!");
17    
18     // get a datagram socket
19     DatagramSocket socket = new DatagramSocket();
20    
21     // send request
22     byte[] buf = text.getBytes();
23     InetAddress address = InetAddress.getByName(args[0]);
24     DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4589);
25     socket.send(packet);
26    
27     String dataOut = new String(packet.getData());
28     System.out.println("Sending: " + dataOut);
29    
30     socket.close();
31     }
32     }