// 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) 
package clisrv;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Client2 {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("localhost", 12345);
        ExtraEnhancedSocket.Writer wrt = ExtraEnhancedSocket.getWriter(s);
        ExtraEnhancedSocket.Reader rdr = ExtraEnhancedSocket.getReader(s);
        wrt.write("z1.zip");
        String sts = (String)rdr.read();
        if(sts.equals("OK")) {
            OutputStream f = new FileOutputStream("C:/work/z2.zip");
            ExtraEnhancedSocket.streamCopy((InputStream)rdr.read(), f);
            f.close();
        }
        rdr.close();
        wrt.close();
    }
}
