6 public class NetsClient extends Thread {
9 static int sendoption=0;
11 public static void main(String argv[]) {
14 int numberofclients=0;
15 int numberofmessages=0;
18 NetsClient.debug=false;
21 port=Integer.parseInt(argv[1]);
22 numberofclients=Integer.parseInt(argv[2]);
23 numberofmessages=Integer.parseInt(argv[3]);
26 System.out.println("NetsClient host port numberofclients numberofmessages debugflag");
29 NetsClient.debug=(Integer.parseInt(argv[4])==1);
30 NetsClient.sendoption=Integer.parseInt(argv[5]);
31 } catch (Exception e) {}
33 NetsClient[] tarray=new NetsClient[numberofclients];
34 for (int i = 0; i < numberofclients; i++) {
36 tarray[i] = new NetsClient(i, host, port,
37 numberofmessages, numberofclients, room);
39 System.out.println("Attempting to start "+i);
43 long starttime=System.currentTimeMillis();
44 for (int i = 0; i < numberofclients; i++)
47 for (int i = 0; i < numberofclients; i++) {
50 } catch (InterruptedException e) {
52 System.out.println(e);
54 long endtime=System.currentTimeMillis();
56 System.out.println("ChatClient");
57 System.out.println("numclients:" + numberofclients);
58 System.out.println("port:" + port);
59 System.out.println("number of messages:" + numberofmessages);
60 System.out.println("Elapsed time:(mS)" + (endtime - starttime));
61 System.out.println("Throughput:" + (double) numberofclients*
62 ((sendoption==4) ? 1 : numberofclients) *
63 numberofmessages/((double) (endtime-starttime)));
66 public NetsClient(int clientnumber, String host,
67 int port, int nom, int noc, String room) {
69 this.clientnumber=clientnumber;
77 int nom, noc,clientnumber,port;
83 //DataInputStream din;
86 public void connectt() {
88 sock = new Socket(host, port); // unix server
90 System.out.println("connection made");
91 in = sock.getInputStream();
92 out = sock.getOutputStream();
93 pout = new PrintStream(out);
94 //din = new DataInputStream(in);
95 d = new BufferedReader(new InputStreamReader(in));
98 catch (UnknownHostException e ) {
99 System.out.println("can't find host");
101 catch (IOException e) {
102 System.out.println("Error connecting to host");
108 System.out.println("client thread started");
112 for(int nr=0;nr<noc*nom;) {
113 if ((ns<nom)&&((nr%noc)==clientnumber)) {
115 pout.println("0|"+clientnumber+"|hello#"+ns+"**");
117 String request = d.readLine();
119 System.out.println(request+nr);
124 catch (UnknownHostException e ) {System.out.println("can't find host"); }
125 catch ( IOException e ) {System.out.println("Error connecting to host");}
129 } // end of client class