MCPcopy Create free account
hub / github.com/PABannier/bark.cpp / select_write

Function select_write

examples/server/httplib.h:2718–2744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2716}
2717
2718inline ssize_t select_write(socket_t sock, time_t sec, time_t usec) {
2719#ifdef CPPHTTPLIB_USE_POLL
2720 struct pollfd pfd_read;
2721 pfd_read.fd = sock;
2722 pfd_read.events = POLLOUT;
2723
2724 auto timeout = static_cast<int>(sec * 1000 + usec / 1000);
2725
2726 return handle_EINTR([&]() { return poll(&pfd_read, 1, timeout); });
2727#else
2728#ifndef _WIN32
2729 if (sock >= FD_SETSIZE) { return 1; }
2730#endif
2731
2732 fd_set fds;
2733 FD_ZERO(&fds);
2734 FD_SET(sock, &fds);
2735
2736 timeval tv;
2737 tv.tv_sec = static_cast<long>(sec);
2738 tv.tv_usec = static_cast<decltype(tv.tv_usec)>(usec);
2739
2740 return handle_EINTR([&]() {
2741 return select(static_cast<int>(sock + 1), nullptr, &fds, nullptr, &tv);
2742 });
2743#endif
2744}
2745
2746inline Error wait_until_socket_is_ready(socket_t sock, time_t sec,
2747 time_t usec) {

Callers 2

is_writableMethod · 0.85

Calls 1

handle_EINTRFunction · 0.85

Tested by

no test coverage detected