#pragma once
#include "TCPSocket.h"

namespace td {
namespace network {

class TCPListener {
    int m_Handle;
    std::uint16_t m_Port;
    int m_MaxConnections;

public:
    TCPListener();
    ~TCPListener();

    bool listen(std::uint16_t port, int maxConnections);
    bool accept(TCPSocket& newSocket);

    void destroy();
    bool close();
    bool setBlocking(bool blocking);

    std::uint16_t getListeningPort() const {
        return m_Port;
    }
    int getMaximumConnections() const {
        return m_MaxConnections;
    }

    REMOVE_COPY(TCPListener);
};

} // namespace network
} // namespace td