// 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.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class SimpleClient {
    public static void main(String[] args) throws IOException, InterruptedException {
        Socket s = new Socket("localhost", 12345);
        OutputStream os = s.getOutputStream();
        InputStream is = s.getInputStream();
        int b;
        os.write(1);
        b = is.read();
        System.out.println(b);
        Thread.sleep(6000);
        os.write(2);
        b = is.read();
        System.out.println(b);
        Thread.sleep(6000);
        os.write(3);
        b = is.read();
        System.out.println(b);
        Thread.sleep(6000);
        os.write(4);
        b = is.read();
        System.out.println(b);
        os.close();
        is.close();
        s.close();
    }
}
