MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / select_read

Function select_read

examples/server/httplib.h:2391–2417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2389}
2390
2391inline ssize_t select_read(socket_t sock, time_t sec, time_t usec) {
2392#ifdef CPPHTTPLIB_USE_POLL
2393 struct pollfd pfd_read;
2394 pfd_read.fd = sock;
2395 pfd_read.events = POLLIN;
2396
2397 auto timeout = static_cast<int>(sec * 1000 + usec / 1000);
2398
2399 return handle_EINTR([&]() { return poll(&pfd_read, 1, timeout); });
2400#else
2401#ifndef _WIN32
2402 if (sock >= FD_SETSIZE) { return 1; }
2403#endif
2404
2405 fd_set fds;
2406 FD_ZERO(&fds);
2407 FD_SET(sock, &fds);
2408
2409 timeval tv;
2410 tv.tv_sec = static_cast<long>(sec);
2411 tv.tv_usec = static_cast<decltype(tv.tv_usec)>(usec);
2412
2413 return handle_EINTR([&]() {
2414 return select(static_cast<int>(sock + 1), &fds, nullptr, nullptr, &tv);
2415 });
2416#endif
2417}
2418
2419inline ssize_t select_write(socket_t sock, time_t sec, time_t usec) {
2420#ifdef CPPHTTPLIB_USE_POLL

Callers 5

is_socket_aliveFunction · 0.85
keep_aliveFunction · 0.85
is_readableMethod · 0.85
httplib.hFile · 0.85

Calls 1

handle_EINTRFunction · 0.85

Tested by

no test coverage detected