<commit_before>#ifndef SERVER_NETCOM_HPP
#define SERVER_NETCOM_HPP

#include <netcom_base.hpp>
#include <SFML/Network.hpp>

namespace server {
    class netcom : public netcom_base {
    public :
        netcom();
        ~netcom();

        void set_max_client(std::size_t max_client);

        void run(std::uint16_t port);
        void terminate();

    private :
        struct client_t {
            std::unique_ptr<sf::TcpSocket> socket;
            actor_id_t                     id;
        };

        using client_list_t = sorted_vector<client_t, mem_var_comp(&client_t::id)>;

        void loop_();
        bool make_id_(actor_id_t& id);
        void free_id_(actor_id_t id);
        void remove_client_(actor_id_t cid);
        void remove_client_(client_list_t::iterator ic);

        std::uint16_t      listen_port_;
        std::size_t        max_client_;
        sf::TcpListener    listener_;
        sf::SocketSelector selector_;

        client_list_t             clients_;
        sorted_vector<actor_id_t, std::greater<request_id_t>> available_ids_;

        bool       terminate_thread_;
        sf::Thread listener_thread_;
    };<commit_msg>Added comments to server::netcom.<commit_after>#ifndef SERVER_NETCOM_HPP
#define SERVER_NETCOM_HPP

#include <netcom_base.hpp>
#include <SFML/Network.hpp>

namespace server {
    class netcom : public netcom_base {
    public :
        netcom();
        ~netcom();

        /// Define the maximum number of simultaneously connected clients.
        /** If the limit is decreased and there are more connected clients than what is now allowed,
            no client will be disconnected. This will only prevent new clients to connect, until the
            new client limit is reached.
        **/
        void set_max_client(std::size_t max_client);

        /// Start the server, listening to the given port.
        void run(std::uint16_t port);

        /// Shut down the server cleanly (called by the destructor).
        /** Calling this function on a server that is not running has no effect.
        **/
        void terminate();

    private :
        struct client_t {
            std::unique_ptr<sf::TcpSocket> socket;
            actor_id_t                     id;
        };

        using client_list_t = sorted_vector<client_t, mem_var_comp(&client_t::id)>;

        void loop_();
        bool make_id_(actor_id_t& id);
        void free_id_(actor_id_t id);
        void remove_client_(actor_id_t cid);
        void remove_client_(client_list_t::iterator ic);

        std::uint16_t      listen_port_;
        std::size_t        max_client_;
        sf::TcpListener    listener_;
        sf::SocketSelector selector_;

        client_list_t             clients_;
        sorted_vector<actor_id_t, std::greater<request_id_t>> available_ids_;

        bool       terminate_thread_;
        sf::Thread listener_thread_;
    };
{'fraction_non_alphanumeric': 0.08448275862068966, 'fraction_numerical': 0.002758620689655172, 'mean_word_length': 2.2816742081447963, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4101119', 'n_tokens_mistral': 863, 'n_tokens_neox': 832, 'n_words': 211}