diff options
Diffstat (limited to 'libnl_2/socket.c')
-rw-r--r-- | libnl_2/socket.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libnl_2/socket.c b/libnl_2/socket.c index e94eb9e..f51cf56 100644 --- a/libnl_2/socket.c +++ b/libnl_2/socket.c @@ -18,6 +18,7 @@ #include <errno.h> #include <unistd.h> +#include <fcntl.h> #include <malloc.h> #include <sys/time.h> #include <sys/socket.h> @@ -139,3 +140,14 @@ struct nl_cb *nl_socket_get_cb(struct nl_sock *sk) { return nl_cb_get(sk->s_cb); } + +int nl_socket_set_nonblocking(struct nl_sock *sk) +{ + if (sk->s_fd == -1) + return -NLE_BAD_SOCK; + + if (fcntl(sk->s_fd, F_SETFL, O_NONBLOCK) < 0) + return -errno; + + return 0; +} |