@@ -30,39 +30,8 @@ public static void main(String[] args) {
3030 }
3131
3232 public static void server () throws Exception {
33- System .out .println ("Starting File Sync Server!" );
34-
35- ServerSocket servsock = new ServerSocket (PORT_NUMBER );
36-
37- while (true ) {
38- Socket sock = servsock .accept ();
39-
40- ObjectInputStream ois = new ObjectInputStream (sock .getInputStream ());
41- String baseDir = (String ) ois .readObject ();
42-
43- File fBaseDir = new File (baseDir );
44-
45- if (fBaseDir .exists () && fBaseDir .isDirectory ()){
46- System .out .println (baseDir + " is a directory and exists!" );
47- /* System.out.print("Sending file '" + fileName + "' to: " + sock.getInetAddress() + "...");
48- ObjectOutputStream oos = new ObjectOutputStream(sock.getOutputStream());
49- oos.writeObject("1");
50- byte[] mybytearray = new byte[(int) f.length()];
51- BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f));
52- bis.read(mybytearray, 0, mybytearray.length);
53- OutputStream os = sock.getOutputStream();
54- os.write(mybytearray, 0, mybytearray.length);
55- os.flush();
56- System.out.println(" DONE!");
57- */ }else {
58- System .out .println (baseDir + " Exists?: " + fBaseDir .exists () + " IsDirectory?: " + fBaseDir .isDirectory ());
59- /* System.out.println(sock.getInetAddress() + " requested " + fileName + ", but it does not exist!");
60- ObjectOutputStream oos = new ObjectOutputStream(sock.getOutputStream());
61- oos.writeObject("0");
62- oos.flush();
63- */ }
64- sock .close ();
65- }
33+ Server s = new Server (PORT_NUMBER );
34+ s .startServer ();
6635 }
6736
6837 public static void client (String dirName , String serverIP ) throws Exception {
0 commit comments