#endif
}
+/*
+ * Set the non-blocking-ness of the socket.
+ */
+
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_nonblocking(rk_socket_t sock, int nonblock)
+{
+#if defined(O_NONBLOCK)
+ int flags = fcntl(sock, F_GETFL, 0);
+ if (flags == -1)
+ return;
+ if (nonblock)
+ flags |= O_NONBLOCK;
+ else
+ flags &= ~O_NONBLOCK;
+ fcntl(sock, F_SETFL, flags);
+#elif defined(FIOBIO)
+ int flags = !!nonblock;
+ return ioctl(sock, FIOBIO, &flags);
+#endif
+}
+
/*
* set the reuse of addresses on `sock' to `val'.
*/
#endif
}
+/*
+ * Set the that the `sock' keepalive setting.
+ */
+
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
+socket_set_keepalive(rk_socket_t sock, int val)
+{
+ setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, sizeof(val));
+}
+
/**
* Create a file descriptor from a socket
*