ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/client/javacli/FakeServer.java
Revision: 1.2
Committed: Sat May 18 18:15:56 2002 UTC (22 years, 6 months ago) by tdb
Branch: MAIN
Changes since 1.1: +19 -0 lines
Log Message:
i-scream is now licensed under the GPL. I've added the GPL headers to every
source file, and put a full copy of the license in the appropriate places.
I think I've covered everything. This is going to be a mad commit ;)

File Contents

# Content
1 /*
2 * i-scream central monitoring system
3 * Copyright (C) 2000-2002 i-scream
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 // used for testing the java CLI client
21
22 import java.net.*;
23 import java.io.*;
24
25 public class FakeServer {
26
27 public static void main(String[] args) throws InterruptedException {
28
29 final int serverPort = 2345;
30 boolean running = true;
31
32 while(running) {
33 OutputStreamWriter writer = null;
34 try {
35 ServerSocket listen = new ServerSocket(serverPort);
36 Socket conn = listen.accept();
37 OutputStream outStream = conn.getOutputStream();
38 writer = new OutputStreamWriter(outStream);
39 System.out.println(">>> Server restarted.");
40 }
41 catch (Exception e) {
42 // Hide and scream.
43 }
44
45 try {
46 while(running) {
47 Thread.sleep(500);
48 String packet = "<packet machine_name=\"raptor\" ip=\"123.123.123.123\"><load><load1>"+Math.random()+"</load1><load5>"+Math.random()+"</load5><load15>"+Math.random()+"</load15></load></packet>\n";
49 writer.write(packet);
50 writer.flush();
51 System.out.println("Packet sent.");
52 }
53 }
54 catch (Exception e) {
55 System.out.println("arg");
56 }
57
58
59 }
60
61
62 }
63
64 }