// 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.*;
import java.net.*;

public class Server3 {
    public static void main(String[] args) throws Exception {
        ServerSocket ss = new ServerSocket(9999);
        Socket s = ss.accept();
        DataOutputStream os = new DataOutputStream(s.getOutputStream());
        download("C:\\z1.zip", os);
        download("C:\\z2.zip", os);
        download("C:\\z3.zip", os);
        os.close();
    }
    public static void download(String filename, DataOutputStream os) throws Exception {
        int size = (int)(new File(filename)).length();
        os.writeInt(size);
        InputStream is = new FileInputStream(filename);
        byte[] b = new byte[10000];
        int n;
        while((n = is.read(b)) >= 0) {
            os.write(b, 0, n);
        }
        is.close();
    }
}
