#define _GNU_SOURCE #include #include #include int (*real_recv)(int, void *, size_t, int) = NULL; int recv(int s, void *buf, size_t len, int flags) { int ret; if (!real_recv) real_recv = dlsym(RTLD_NEXT, "recv"); if (!real_recv) { fprintf(stderr, "!!! Could not resolve 'recv'!\n"); errno = ENOSYS; return -1; } if ((ret = real_recv(s, buf, len, flags)) == -1 && errno == EAGAIN) errno = EINPROGRESS; return ret; }