ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/XMLReader/XMLSender2.java
Revision: 1.1
Committed: Fri Nov 17 15:54:04 2000 UTC (24 years ago) by pjm2
Branch: MAIN
Log Message:
Sends an XML UDP packet to port 6667 (about 100 times per second).
The packet contains an id number so we can see how many get lost,
etc.

File Contents

# Content
1 import java.io.*;
2 import java.net.*;
3 import java.util.*;
4
5 // Class used to send lots of arbitrary crap to the XMLReader
6
7 public class XMLSender2 {
8 public static void main(String[] args) throws Exception {
9
10 if (args.length != 1) {
11 System.out.println("Usage: java XMLSender <hostname>");
12 System.exit(0);
13 }
14
15 System.out.println("Repeatedly sending the same packet to port 6667 ...");
16 System.out.println("(about 100 per second, with id numbers)");
17
18 int port = 6667;
19
20 // stuff to send
21
22
23 // get a datagram socket
24 DatagramSocket socket = new DatagramSocket();
25 InetAddress address = InetAddress.getByName(args[0]);
26
27 int id = 0;
28 boolean running = true;
29 while (running){
30 id++;
31 String xml = "<packet><id>"+id+"</id></packet>";
32 byte[] buf = xml.getBytes();
33 DatagramPacket packet = new DatagramPacket(buf, buf.length, address, port);
34 // send request repeatedly
35 socket.send(packet);
36 Thread.sleep(10);
37 }
38
39 socket.close();
40 }
41 }