6 public class NetsClient extends Thread {
10 public static void main(String argv[]) {
13 int numberofclients=0;
14 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]);
24 groups=Integer.parseInt(argv[4]);
27 System.out.println("NetsClient host port numberofclients numberofmessages debugflag");
30 NetsClient.debug=(Integer.parseInt(argv[5])==1);
31 } catch (Exception e) {}
33 NetsClient[][] tarray=new NetsClient[groups][numberofclients];
34 for (int g=0;g<groups;g++) {
35 for (int i = 0; i < numberofclients; i++) {
36 String room="group"+g;
37 tarray[g][i] = new NetsClient(i, host, port,
38 numberofmessages, numberofclients, room);
40 System.out.println("Attempting to start "+i);
41 tarray[g][i].connectt();
46 } catch (Exception e) {};
47 for (int i = 0; i < numberofclients; i++)
50 for (int i = 0; i < numberofclients; i++) {
53 } catch (InterruptedException e) {
55 System.out.println(e);
60 for (int g=0;g<groups;g++)
61 for(int i=0;i<numberofclients;i++)
62 messages+=tarray[g][i].lines;
64 System.out.println("ChatClient");
65 System.out.println("numclients:" + numberofclients);
66 System.out.println("groups:"+groups);
67 System.out.println("port:" + port);
68 System.out.println("number of messages:" + numberofmessages);
70 System.out.println("Lines="+messages+" out of "+groups*numberofclients*(numberofclients-1)*numberofmessages);
73 public NetsClient(int clientnumber, String host,
74 int port, int nom, int noc, String room) {
76 this.clientnumber=clientnumber;
84 int nom, noc,clientnumber,port;
90 //DataInputStream din;
94 public void connectt() {
96 sock = new Socket(host, port); // unix server
98 System.out.println("connection made");
99 in = sock.getInputStream();
100 out = sock.getOutputStream();
101 pout = new PrintStream(out);
102 //din = new DataInputStream(in);
106 catch (UnknownHostException e ) {
107 System.out.println("can't find host");
109 catch (IOException e) {
110 System.out.println("Error connecting to host");
116 System.out.println("client thread started");
120 for(int nr=0;nr<noc*nom;nr++) {
121 if ((nr%noc)==clientnumber) {
123 pout.println(room+"|"+clientnumber+"|hello#"+ns);
125 while(in.available()>0) {
132 long time=System.currentTimeMillis();
133 while((System.currentTimeMillis()-time)<8*1000) {
134 if(in.available()>0) {
136 time=System.currentTimeMillis();
139 } else try {Thread.sleep(2);} catch (Exception e) {}
143 catch (UnknownHostException e ) {System.out.println("can't find host"); }
144 catch ( IOException e ) {System.out.println("Error connecting to host");}
148 } // end of client class