10#include <netinet/in.h>
11#include <netinet/tcp.h>
14#include <sys/socket.h>
20using SocketHandle = int;
21constexpr SocketHandle INVALID_SOCKET_HANDLE = -1;
22using SocketLength = socklen_t;
26 SocketRuntime() =
default;
27 ~SocketRuntime() =
default;
30inline void ensureSocketRuntime() {
35inline void closeSocket(SocketHandle socket) { ::close(socket); }
36inline int socketLastError() {
return errno; }
38inline bool socketWouldBlock(
int error) {
39 return error == EWOULDBLOCK || error == EAGAIN;
41inline bool socketConnectionReset(
int error) {
return error == ECONNRESET; }
43inline bool setSocketNonBlocking(SocketHandle socket,
bool enabled =
true) {
44 int flags = fcntl(socket, F_GETFL, 0);
45 return flags >= 0 && fcntl(socket, F_SETFL, enabled ? flags | O_NONBLOCK
46 : flags & ~O_NONBLOCK) == 0;
Definition DesktopSocketPosix.h:24
We provide the WiFi class to simulate the Arduino WIFI. In in Linux we can expect that networking is ...
Definition CanMsg.cpp:31