package com.lona.tictactoe.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class GameServer {
    public static final int PORT = 1870;
    private static final ExecutorService pool = Executors.newFixedThreadPool(100);

    public static void main(String[] args) {
        System.out.println("Starting TicTacToe Server on port " + PORT + "...");
        try (ServerSocket listener = new ServerSocket(PORT)) {
            while (true) {
                Socket client = listener.accept();
                System.out.println("Client connected: " + client.getRemoteSocketAddress());
                pool.execute(new ClientHandler(client));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
