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

Function fcntl

src/platforms/win/socket_win.cpp.hpp:278–298  ·  view source on GitHub ↗

fcntl emulation for non-blocking sockets

Source from the content-addressed store, hash-verified

276
277// fcntl emulation for non-blocking sockets
278int fcntl(int fd, int cmd, ...) FL_NOEXCEPT {
279 SOCKET sock = static_cast<SOCKET>(fd);
280
281 if (cmd == F_GETFL) {
282 // Windows doesn't provide a way to query non-blocking status
283 // Return 0 (blocking) as default
284 return 0;
285 } else if (cmd == F_SETFL) {
286 va_list args;
287 va_start(args, cmd);
288 int flags = va_arg(args, int);
289 va_end(args);
290
291 u_long mode = (flags & O_NONBLOCK) ? 1 : 0;
292 int result = ioctlsocket(sock, FIONBIO, &mode);
293 return (result == SOCKET_ERROR) ? -1 : 0;
294 }
295
296 WSASetLastError(WSAEINVAL);
297 return -1;
298}
299
300// Note: get_errno() is provided by fl/stl/cerrno.h
301// Note: Platform abstraction functions (create_platform_socket, etc.) are not needed

Callers 3

handle_dns_lookupMethod · 0.50
set_nonblockingFunction · 0.50
set_nonblockingFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected