public static void server(int port) throws IOException, InterruptedException{
        
        ServerSocket server = new ServerSocket(port);
        Socket socket;
        
        while (true){
            socket = server.accept();
            System.out.println(socket.getRemoteSocketAddress().toString() + " connected");
        
            
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            while ((alg = in.readLine()).equals(null)){}
            while ((file = in.readLine()).equals(null)){}
            System.out.println("Recieved " + alg + " + " + file);
            System.out.println("Opened " + path + "/files/" + file);
            
            FileInputStream fileIn = new FileInputStream(new File(path + "files/" + file + ".txt"));
            
            @SuppressWarnings("unused")
			ByteArrayOutputStream bArrayout = new ByteArrayOutputStream();
            
            
            BufferedInputStream bis = new BufferedInputStream(fileIn);
            ByteArrayOutputStream bOut = new ByteArrayOutputStream();
            BufferedOutputStream bos = new BufferedOutputStream(bOut);
            
            if (alg.toLowerCase().equals("huffman")){
                HuffmanCompress(bis, bos);
                bis.close();
                bos.close();
            }
            else if (alg.toLowerCase().equals("lzw")){
                LZWCompress(bis, bos);
                bis.close();
                bos.close();
            }
            else if (alg.toLowerCase().equals("runlength")){
                BinaryRunCom(bis, bos);
                bis.close();
                bos.close();
            }
            else if (alg.toLowerCase().equals("arithmetic")){
                AdaptiveArithmeticCompress.Comp(bis, bos);
                bis.close();
                bos.close();
            }
            else if (alg.toLowerCase().equals("deflate")){
               DeflateCompress(bis, bos);
               bis.close();
               bos.close();
            }
            else if(alg.equals("raw")) {
            	rawData(bis, bos);
            	bis.close();
            	bos.close();
            }
            
            System.out.println("Compressed data sent");
            byte[] compressed = bOut.toByteArray();
            IOUtils.copy(new ByteArrayInputStream(compressed), socket.getOutputStream());
            System.out.println(compressed.length + " compressed file bytes length");
            //close all
            in.close();
            fileIn.close();
            socket.close();
        }
    }