ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/XMLReader/XMLSender2.java
Revision: 1.3
Committed: Tue Nov 21 09:26:09 2000 UTC (23 years, 5 months ago) by pjm2
Branch: MAIN
CVS Tags: PROJECT_COMPLETION, HEAD
Changes since 1.2: +3 -3 lines
Log Message:
Modified the port number used by XMLSender2.

Altered UDPReaderThread such that a 'proper' thread is run.

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 4589 ...");
16 System.out.println("(*about* 100 per second, with id numbers)");
17
18 int port = 4589;
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(1);
37 }
38
39 socket.close();
40 }
41 }