package com.zipcoder.server;


import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    private ServerSocket serverSocket;

    public Server(int port) throws IOException {
        this.serverSocket = new ServerSocket(5000);
    }

    public Server(ServerSocket socket) {
        this.serverSocket = socket;
    }

    public void start() throws IOException {
        while(!serverSocket.isClosed()){
            Socket clientSocket = serverSocket.accept();
            RequestHandler handler = new RequestHandler(clientSocket);
            handler.run();
        }
    }
}