// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

import static netperf.Constants.*;

public class Sender {
    public static void test(OutputStream os, int size) throws IOException {
        byte[] b = new byte[size];
        for(int j = 0; j < size; j++) b[j] = (byte)(size % 256);
        for(int i = 0; i < REP; i++) {
            os.write(b);
            os.flush();
        }
    }
    public static void main(String[] args) throws UnknownHostException, IOException {
        Socket s = new Socket(args[0], 12345);
        OutputStream os = s.getOutputStream();
        for(int size = START_SIZE; size <= END_SIZE; size += INCR_SIZE) {
            test(os, size);
        }
        os.close();
    }
}
