// 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 Client2 {
   public static void main(String[] args) throws Exception {
      Socket s = new Socket("localhost", 9999);
      DataOutputStream os = new DataOutputStream(s.getOutputStream());
      upload("C:\\z1.zip", os);
      upload("C:\\z2.zip", os);
      upload("C:\\z3.zip", os);
      os.close();
   }
   public static void upload(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();
   }
}
