MCPcopy Create free account
hub / github.com/ddnet/ddnet / net_set_blocking_impl

Function net_set_blocking_impl

src/base/net.cpp:671–697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

669}
670
671static int net_set_blocking_impl(NETSOCKET sock, bool blocking)
672{
673 unsigned long mode = blocking ? 0 : 1;
674 const char *mode_str = blocking ? "blocking" : "non-blocking";
675 int sockets[] = {sock->ipv4sock, sock->ipv6sock};
676 const char *socket_str[] = {"IPv4", "IPv6"};
677
678 for(size_t i = 0; i < std::size(sockets); ++i)
679 {
680 if(sockets[i] >= 0)
681 {
682#if defined(CONF_FAMILY_WINDOWS)
683 if(ioctlsocket(sockets[i], FIONBIO, (unsigned long *)&mode) != NO_ERROR)
684 {
685 log_error("net", "Setting %s mode for %s socket failed (%s)", socket_str[i], mode_str, net_error_message().c_str());
686 }
687#else
688 if(ioctl(sockets[i], FIONBIO, (unsigned long *)&mode) == -1)
689 {
690 log_error("net", "Setting %s mode for %s socket failed (%s)", socket_str[i], mode_str, net_error_message().c_str());
691 }
692#endif
693 }
694 }
695
696 return 0;
697}
698
699int net_set_non_blocking(NETSOCKET sock)
700{

Callers 2

net_set_non_blockingFunction · 0.85
net_set_blockingFunction · 0.85

Calls 1

net_error_messageFunction · 0.85

Tested by

no test coverage detected