import java.io.*; import java.net.*; import java.io.IOException; import java.net.UnknownHostException; public class Client { static String msg; static int msgnum = 5000; // static PrintWriter out = null; static DataOutputStream out = null; public static void main(String[] args) throws IOException { int round = 1; int blocksize = 1024; Socket kkSocket = null; String servername; if (args.length != 3 ) return; servername = args[0]; blocksize = Integer.parseInt(args[1]); msgnum = Integer.parseInt(args[2]); byte[] msgbyte = new byte[blocksize]; for(int i = 0; i < blocksize; i++) msgbyte[i] = 'H'; msg = new String(msgbyte); try { kkSocket = new Socket(); InetSocketAddress addr = new InetSocketAddress(servername, 4444); kkSocket.connect(addr); // out = new PrintWriter(kkSocket.getOutputStream(), true); out = new DataOutputStream(kkSocket.getOutputStream()); } catch (UnknownHostException e) { System.err.println("Don't know about host: 127.0.0.1."); System.exit(1); } catch (IOException e) { System.err.println("Couldn't get I/O for the connection to: 127.0.0.1."); e.printStackTrace(); System.exit(1); } long start , end; start = System.currentTimeMillis(); test(); end = System.currentTimeMillis(); System.out.println(" Time Overhead :"+(float)(end-start)/msgnum); System.out.println("Block size: " + blocksize); System.out.println("Sending " + msgnum + " done"); out.close(); kkSocket.close(); } public static void test() { try{ for(int i = 0; i < msgnum; i++){ out.writeBytes(msg+"\n"); } }catch(IOException e){ e.printStackTrace(); } } }