MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / select_write

Function select_write

external/httplib.h:3108–3134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3106}
3107
3108inline ssize_t select_write(socket_t sock, time_t sec, time_t usec) {
3109#ifdef CPPHTTPLIB_USE_POLL
3110 struct pollfd pfd_read;
3111 pfd_read.fd = sock;
3112 pfd_read.events = POLLOUT;
3113
3114 auto timeout = static_cast<int>(sec * 1000 + usec / 1000);
3115
3116 return handle_EINTR([&]() { return poll(&pfd_read, 1, timeout); });
3117#else
3118#ifndef _WIN32
3119 if (sock >= FD_SETSIZE) { return -1; }
3120#endif
3121
3122 fd_set fds;
3123 FD_ZERO(&fds);
3124 FD_SET(sock, &fds);
3125
3126 timeval tv;
3127 tv.tv_sec = static_cast<long>(sec);
3128 tv.tv_usec = static_cast<decltype(tv.tv_usec)>(usec);
3129
3130 return handle_EINTR([&]() {
3131 return select(static_cast<int>(sock + 1), nullptr, &fds, nullptr, &tv);
3132 });
3133#endif
3134}
3135
3136inline Error wait_until_socket_is_ready(socket_t sock, time_t sec,
3137 time_t usec) {

Callers 2

is_writableMethod · 0.85

Calls 1

handle_EINTRFunction · 0.85

Tested by

no test coverage detected