package cc.glsn; import java.net.Socket; import java.io.InputStream; import java.io.OutputStream; import java.util.Random; public class GarbageToss { public static void main(String Args[]) throws Exception { String Host=Args[0]; int Port=new Integer(Args[1]).intValue(); new GarbageToss(Host,Port); } public GarbageToss(String Host, int Port) throws Exception { Random R=new Random(); while(true) { try { System.out.println("Connecting..."); Socket S=new Socket(Host,Port); while(S.isConnected()) { readInput(S.getInputStream()); int W=R.nextInt(1000)+1; byte[] Buff=new byte[W]; R.nextBytes(Buff); System.out.println(" writing " + W + " bytes."); writeOutput(S.getOutputStream(),Buff); } } catch(Exception e) { e.printStackTrace(); } } } private void readInput(InputStream IN) throws Exception { while(true) { int B=IN.available(); if (B==0) return; byte[] Buff=new byte[B]; IN.read(Buff,0,B); } } private void writeOutput(OutputStream Out, byte[] Buff) throws Exception { Out.write(Buff,0,Buff.length); } }