/*
 * The MIT License
 *
 * Copyright 2016 andrew.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.github.agsimmons.wordpiles.server;

public class Server {
    
}

@@ -1123,17 +1123,16 @@
 RE.%0A */%0A
-%0A
 package 
@@ -1175,33 +1175,2059 @@
 r;%0A%0A
-public class Server %7B%0A    
+import java.io.IOException;%0Aimport java.net.ServerSocket;%0Aimport java.net.Socket;%0Aimport java.util.Scanner;%0A%0Apublic class Server %7B%0A%0A    private final int DEFAULT_PORT = 8888;%0A%0A    private int port;%0A%0A    private ServerSocket serverSocket;%0A    private Socket playerOne;%0A    private Socket playerTwo;%0A%0A    public Server() %7B%0A        chooseServerPort();%0A        createServerSocket();%0A        createClientSockets();%0A    %7D%0A%0A    private void chooseServerPort() %7B%0A        Scanner scanner = new Scanner(System.in);%0A        String input;%0A%0A        boolean validPort = false;%0A        do %7B%0A%0A            boolean portChosen = false;%0A            do %7B%0A%0A                System.out.print(%22Server Port (%22 + DEFAULT_PORT + %22): %22);%0A                input = scanner.nextLine();%0A                if (input.equals(%22%22)) %7B%0A                    port = DEFAULT_PORT;%0A                    portChosen = true;%0A                %7D else %7B%0A                    try %7B%0A                        port = Integer.parseInt(input);%0A                        portChosen = true;%0A                    %7D catch (NumberFormatException e) %7B%0A                        System.out.println(%22ERROR: Invalid port!%22);%0A                    %7D%0A                %7D%0A%0A            %7D while (!portChosen);%0A%0A            // Check if port is already in use%0A            try %7B%0A                (new ServerSocket(port)).close();%0A                validPort = true;%0A            %7D catch (IOException ex) %7B%0A                System.out.println(%22ERROR: Could not bind to port! It could be in use or reserved. Please choose a different port%22);%0A            %7D%0A%0A        %7D while (!validPort);%0A    %7D%0A%0A    private void createServerSocket() %7B%0A        try %7B%0A            serverSocket = new ServerSocket(port);%0A        %7D catch (IOException ex) %7B%0A            System.out.println(%22ERROR: Could not create server socket!%22);%0A            System.out.println(%22This error is not handled yet. Shutting Down!%22);%0A            System.exit(1);%0A        %7D%0A    %7D%0A%0A    private void createClientSockets() %7B%0A        playerOne = new Socket();%0A        playerTwo = new Socket();%0A    %7D%0A
 %0A%7D%0A

Create Server constructor and it's required methods