public static void main(String[] args) {
    	int timeout = DEFAULT_TIMEOUT;
    	
        if (!(args.length == 2 || args.length == 1)) {
            System.err.println("Usage: java Pop3Server <port number> <timeout>");
            return;
        }
        
    	if(args.length == 2) {
    		timeout = convertStrToInt(args[1]) * 1000;
            if (timeout == -1) {
                System.err.println("-ERR Please enter a valid timeout value in seconds");
                return;
            }
       	}
    	
        int port = convertStrToInt(args[0]);
        if (port == -1) {
            System.err.println("-ERR Please enter a valid port number");
            return;
        }
  
        /* Listening variable can be used to leave the program with a simple if statement */
        boolean listening = true;

        /* On startup and server crashes, resets the locks and marked messages in the database */
        resetDatabase();
        
        /* Creates a server socket with the given port number */
        try (ServerSocket serverSocket = new ServerSocket(port)) { 
        	
            System.out.println("<wait for connection on TCP port " + port + ">");
            while (listening) {
            	/* Creates a new thread with the new class Pop3Session.*/
            	/* Program waits here until a client connects with the given serverSocket */
                new Thread (new Pop3Session(timeout, serverSocket.accept())).start();
            }
        } catch (SocketException se) {
            System.err.println("Could not listen on port " + port);
            return;
        } catch (IOException e) {
            System.err.println("IO Error");
            return;
        }
    }