diff --git a/libc/sys/socket/socket.cpp b/libc/sys/socket/socket.cpp index a6a99561..642eeadb 100644 --- a/libc/sys/socket/socket.cpp +++ b/libc/sys/socket/socket.cpp @@ -63,8 +63,7 @@ static const char* get_socket_factory(int domain, int type, int protocol) extern "C" int socket(int domain, int type, int protocol) { int open_flags = O_RDWR; - // TODO: O_NONBLOCK is not supported! - //if ( type & SOCK_NONBLOCK ) open_flags |= O_NONBLOCK; + if ( type & SOCK_NONBLOCK ) open_flags |= O_NONBLOCK; if ( type & SOCK_CLOEXEC ) open_flags |= O_CLOEXEC; if ( type & SOCK_CLOFORK ) open_flags |= O_CLOFORK; type &= SOCK_TYPE_MASK; diff --git a/sortix/io.cpp b/sortix/io.cpp index 4e58417f..020ea6b4 100644 --- a/sortix/io.cpp +++ b/sortix/io.cpp @@ -630,7 +630,6 @@ static int sys_accept4(int fd, void* addr, size_t* addrlen, int flags) if ( !desc ) return -1; int fdflags = 0; - // TODO: Support SOCK_NONBLOCK if ( flags & SOCK_CLOEXEC ) fdflags |= FD_CLOEXEC; if ( flags & SOCK_CLOFORK ) fdflags |= FD_CLOFORK; flags &= ~(SOCK_CLOEXEC | SOCK_CLOFORK); @@ -638,6 +637,8 @@ static int sys_accept4(int fd, void* addr, size_t* addrlen, int flags) Ref conn = desc->accept(&ctx, (uint8_t*) addr, addrlen, flags); if ( !conn ) return -1; + if ( flags & SOCK_NONBLOCK ) + conn->SetFlags(conn->GetFlags() | O_NONBLOCK); return CurrentProcess()->GetDTable()->Allocate(conn, fdflags); }