This discussion is archived
9 Replies Latest reply: Aug 9, 2013 3:17 AM by masijade RSS

Server socket stress test?

938489 Newbie
Currently Being Moderated

We have a server socket running.  We have simple client programme as below. We would like to do a stress test on our server socket by running the codes below. How can we achieve a parallel effect with the following codes? Normally what limitation will the socket application have e.g. number of socket per minute etc?

[code]

public class stress1 extends Thread {

public static void main(String[] argv) {

try {

   for (int i = 0; i < 5000; i++) {

        Socket socket = new Socket("localhost", 18000);

        PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

        out.println("data to my server ");

        System.out.println(in.readLine() + i);

             out.close();

        in.close();

        socket.close();

       }

    } catch (Exception e) {

      e.printStackTrace();

   }

}

}

[/code]

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points