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

Method accept

src/fl/stl/asio/ip/tcp.cpp.hpp:427–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427error_code acceptor::accept(socket &peer) {
428 if (mFd == -1) {
429 return error_code(errc::operation_aborted, "acceptor not open");
430 }
431
432 struct sockaddr_in clientAddr {};
433 socklen_t addrLen = sizeof(clientAddr);
434 int clientFd =
435 plat_accept(mFd, (struct sockaddr *)&clientAddr, &addrLen);
436
437 if (clientFd < 0) {
438 if (is_would_block()) {
439 return error_code(errc::would_block);
440 }
441#ifdef FL_IS_WIN
442 return error_code(errc::unknown, "accept failed");
443#else
444 return error_code::from_errno(errno);
445#endif
446 }
447
448 // Non-blocking on accepted socket
449 set_nonblocking(clientFd, true);
450 peer.assign(clientFd);
451
452 return error_code();
453}
454
455void acceptor::async_accept(socket &peer, connect_handler handler) {
456 error_code ec = accept(peer);

Callers 3

variant.hFile · 0.45
visit_fn_constFunction · 0.45
acceptClientsMethod · 0.45

Calls 5

error_codeClass · 0.85
plat_acceptFunction · 0.85
is_would_blockFunction · 0.85
set_nonblockingFunction · 0.70
assignMethod · 0.45

Tested by

no test coverage detected