[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] running in main thread

From: Evgeny Grin
Subject: Re: [libmicrohttpd] running in main thread
Date: Wed, 04 Dec 2019 14:51:46 +0300

You can also use very portable and universal solution:
 mhd = MHD_start_daemon(MHD_USE_AUTO, ....
 fd_set rs;
 fd_set ws;
 fd_set es;
 MHD_socket maxsock;
  struct timeval tv;
  struct timeval* tvp;
 unsigned long long tov;
  FD_ZERO (&rs);
  FD_ZERO (&ws);
  FD_ZERO (&es);
  if (MHD_NO == MHD_get_fdset (d, &rs, &ws, &es, &maxsock))
  if (MHD_NO == MHD_get_timeout(mhd, &tov))
    tvp = NULL;
    tv.tv_sec = tov / 1000;
    tv.tv_usec = (tov % 1000) * 1000;
    tvp = &tvp;
 select (maxsock+ 1, &rs, &ws, &es, tvp);
 if (MHD_NO == MHD_run_from_select (d, &rs, &ws, &es)
Add error checking and types casting.
Best Wishes,
Evgeny Grin
03.12.2019, 00:32, "Christian Grothoff" <address@hidden>:

On 12/2/19 10:18 PM, José Bollo wrote:

 Well, that's trivial. Please consider the attached fragment (not
 tested, but should be very close to what you need, modulo error
 I know it is trivial (my implementation below) but I advocate to offer
 a facility that does the job. It avoids tricky aspects like EPOLL and
 get_daemon_info (is working for windows???)

AFAIK on the Windows Subsystem for Linux it should work, and everything
else is a mess to do in a portable way. Regardless, these loops are
usually pretty simple, hence I do still think that they don't belong
into the library. What we could do is at sample loops into the
documentation (tutorial?).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]