public static void main(String args[]) throws Exception {
        String clientMSG[];
        String capitalizedSentence;
        ServerSocket welcomeSocket = new ServerSocket(7000);
        int state = 0;  // 0 = waiting for call
                        // 1 = waiting for ACK
        int timeOut = 1;// how long to wait in ? todo

        while (true){
            // waiting for call
            System.out.println("Waiting for call.");
            Socket connectionSocket = welcomeSocket.accept();
            System.out.println("Recived call.");
            // setup read buffer
            BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
            // setup send buffer
            DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
            
            // ready to start sending and reciving
            try {
                // while connection is not closed process messages
                while(!connectionSocket.isClosed()) {
                    // waiting for message i.e. waiting for call state
                    System.out.println("Waiting for msg.");
                    clientMSG = WaitForMSG(inFromClient);
                    

                    
                    // message unreadable
                    if (clientMSG[0].equals("-1")){
                        System.out.println("Malformed packet - send ACK: -1 to request resend");
                    } else if (clientMSG[0].equals("-2")){
                        System.out.println("CRC failed - sending ACK: -2 to request resend");
                    } else {
                        // we recived msg (#, data, checksum)
                        System.out.println("Recived: " + clientMSG[0] + " Data: " + clientMSG[2] + " Checksum: " + clientMSG[1]);
                        System.out.println("Sending ACK: " + clientMSG[0]);
                    }
                    // send ACK
                    outToClient.writeBytes("ACK:" + clientMSG[0] + "\n");
                    
                } // end while
            } // end try
            catch (IOException e) {
                System.err.println("Caught IOException: " + e.getMessage());
            } // end catch
            System.out.println("CONNECTION CLOSED");
            inFromClient.close();
            outToClient.close();
        } // end while
    } // end main