Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

50 рядки
1.2 KiB

  1. #pragma once
  2. #include <cppcore/conversion/convert_cast.h>
  3. #include "daemon.h"
  4. namespace cppmicrohttpd
  5. {
  6. /* daemon */
  7. MHD_Daemon * daemon::handle() const
  8. { return _handle.get(); }
  9. void daemon::run()
  10. {
  11. if (MHD_run(_handle.get()) != MHD_YES)
  12. throw exception("Unable to execute MHD_run");
  13. }
  14. void daemon::run(
  15. const ::cppcore::fdset& p_read,
  16. const ::cppcore::fdset& p_write,
  17. const ::cppcore::fdset& p_except)
  18. {
  19. if (MHD_run_from_select(_handle.get(), &p_read, &p_write, &p_except) != MHD_YES)
  20. throw exception("Unable to execute MHD_run_from_select");
  21. }
  22. int daemon::prepare_fdsets(
  23. ::cppcore::fdset& p_read,
  24. ::cppcore::fdset& p_write,
  25. ::cppcore::fdset& p_except) const
  26. {
  27. int ret = 0;
  28. if (MHD_get_fdset(_handle.get(), &p_read, &p_write, &p_except, &ret) != MHD_YES)
  29. throw exception("Unable to execute MHD_get_fdset");
  30. return ret;
  31. }
  32. long long daemon::get_timeout() const
  33. {
  34. unsigned long long timeout = 0;
  35. if (MHD_get_timeout(_handle.get(), &timeout) != MHD_YES)
  36. return -1;
  37. return cppcore::convert_cast<long long>(timeout);
  38. }
  39. }