Вот пример базовой структуры моего кода:
Код: Выделить всё
#include
#include
#include "../include/httplib.h"
#include "../include/json.hpp"
using boost::asio::ip::tcp;
static boost::asio::io_context io_context;
static tcp::socket testSocket(io_context);
boost::system::error_code boost_error;
std::string testIP = "192.168.9.114";
std::string testPort = "20000";
int serverPort__ = 8077;
static httplib::Server server_;
namespace RestServer {
std::string what(const std::exception_ptr &eptr = std::current_exception()) {
if (!eptr) { throw std::bad_exception(); }
try { std::rethrow_exception(eptr); }
catch (const std::exception &e) { return e.what() ; }
catch (const std::string &e) { return e ; }
catch (const char *e) { return e ; }
catch (...) { return "who knows"; }
}
int main() {
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79016676/sending-boost-asio-ip-commands-within-a-httplib-rest-server-not-working[/url]