Commit bb1ff757 authored by Pekka Pessi's avatar Pekka Pessi

su.c: making all sockets non-blocking by default.

darcs-hash:20070528085805-65a35-585627f0974cd343a6805ba86154092ad67f9b02.gz
parent 37cfe0fd
......@@ -51,14 +51,18 @@
#endif
int su_socket_close_on_exec = 0;
int su_socket_blocking = 0;
/** Create an endpoint for communication. */
su_socket_t su_socket(int af, int socktype, int proto)
{
su_socket_t s = socket(af, socktype, proto);
#if SU_HAVE_BSDSOCK
if (s != INVALID_SOCKET && su_socket_close_on_exec) {
fcntl(s, F_SETFD, FD_CLOEXEC); /* Close on exec */
if (s != INVALID_SOCKET) {
if (su_socket_close_on_exec)
fcntl(s, F_SETFD, FD_CLOEXEC); /* Close on exec */
if (!su_socket_blocking) /* All sockets are born blocking */
su_setblocking(s, 0);
}
#endif
return s;
......
......@@ -204,6 +204,8 @@ int test_sendrecv(void)
TEST(getsockname(l, &su.su_sa, &sulen), 0);
TEST(listen(l, 5), 0);
TEST(su_setblocking(s, 1), 0);
TEST(connect(s, &su.su_sa, sulen), 0);
a = accept(l, &csu.su_sa, &csulen); TEST_1(a != -1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment