void Server::StartListening() { // init socket std::memset(&_hints, 0, sizeof _hints); _hints.ai_family = AF_UNSPEC; _hints.ai_socktype = SOCK_STREAM; _hints.ai_flags = AI_PASSIVE; std::string port_str = std::to_string(_port); int status; if ((status = getaddrinfo(NULL, port_str.c_str(), &_hints, &_tmp_res)) != 0) { std::string info = gai_strerror(status); throw SocketException(info); } _socket = socket(_tmp_res->ai_family, _tmp_res->ai_socktype, _tmp_res->ai_protocol); bind(_socket, _tmp_res->ai_addr, _tmp_res->ai_addrlen); // listen listen(_socket, max_connections()); log("Listening port: " + std::to_string(_port)); _is_running = true; }
int torrent_handle::max_connections() const { INVARIANT_CHECK; TORRENT_FORWARD_RETURN(max_connections(), 0); }