MCPcopy Create free account
hub / github.com/FastLED/FastLED / accept_connections

Method accept_connections

src/fl/stl/asio/http/server.cpp.hpp:404–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404void Server::accept_connections() {
405 sockaddr_in client_addr{};
406 socklen_t addr_len = sizeof(client_addr);
407
408 // Accept all pending connections (non-blocking)
409 while (true) {
410 int client_fd = accept(mListenSocket,
411 (sockaddr*)(&client_addr),
412 &addr_len);
413
414 if (client_fd < 0) {
415#ifdef FL_IS_WIN
416 if (WSAGetLastError() == SOCKET_ERROR_WOULD_BLOCK) break;
417#else
418 if (errno == EWOULDBLOCK || errno == EAGAIN) break;
419#endif
420 // Other error - log and continue
421 break;
422 }
423
424 // Set client socket to non-blocking
425 if (!set_nonblocking(client_fd)) {
426 close(client_fd);
427 continue;
428 }
429
430 // Add to client list
431 ClientConnection client;
432 client.fd = client_fd;
433 client.connect_time = fl::platforms::millis();
434 mClientSockets.push_back(client);
435 }
436}
437
438size_t Server::process_requests() {
439 size_t requests_processed = 0;

Callers

nothing calls this directly

Calls 5

set_nonblockingFunction · 0.70
acceptFunction · 0.50
closeFunction · 0.50
millisFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected