Jul 122011
 

..


import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;

public class FloodClient1 {
  static final int k_step = 10;
  static byte[] value = new byte[k_step * 1024];

  public static void main(String[] args) throws Exception {
    int i = 0;
    while (i < value.length) {
      value[i++] = 13;
    }
    SocketAddress addr = new InetSocketAddress("localhost", 8080);
    Socket socket = new Socket();
    socket.setSoTimeout(0);
    socket.connect(addr, 0);
    OutputStream os = socket.getOutputStream();
    // InputStream is = socket.getInputStream();
    
    int k = k_step;
    int m = 0;
    int k100 = 100;
    while (m < 2000) {
      if (k >= k100) {
        k100 += 100;
        System.out.print('.');
        System.out.flush();
      }
      if (k >= 1024) {
        m++;
        k -= 1024;
        k100 = 100;
        System.out.println(" " + m + " Mb");
      }
    os.write(value);
    os.flush();
    Thread.sleep(1);
    k+=k_step;
    }
  }
}