Issue #11139 has been updated by Akira Tanaka.


"sock_nonblock kwarg is similar to SOCK_NONBLOCK flag in (future) POSIX" seems intuitive.

Note that accept4 (and its behavior with SOCK_NONBLOCK) will be defined in POSIX (or SUS):
http://austingroupbugs.net/view.php?id=411

It means that O_NONBLOCK flag of the created FD is set if sock_nonblock is true and
O_NONBLOCK flag is unset if sock_nonblock is false.

The behavior should work on the platforms which doesn't have accept4().
Be careful that O_NONBLOCK behavior of accept() is not portable.
http://cr.yp.to/docs/unixport.html

It is not clear that the behavior when sock_nonblock kwarg is not specified.
I feel that it should be defined anyway.
It may reduce the portability problem a bit.


----------------------------------------
Feature #11139: [PATCH] socket: accept_nonblock supports "nonblock: false" kwarg
https://bugs.ruby-lang.org/issues/11139#change-52940

* Author: Eric Wong
* Status: Feedback
* Priority: Normal
* Assignee: Akira Tanaka
----------------------------------------
[PATCH 2/2] socket: accept_nonblock supports "nonblock: false" kwarg

An application wanting to do non-blocking accept may want to create a
blocking accepted socket, allow it with a kwarg while preserving default
behavior.

If this patch is accepted, I'd also like to support the opposite
for blocking accept calls:

	a = s.accept(nonblock: true) # blocking accept syscall
	a.nonblock? # => true
	s.nonblock? # => false

This requires the simple patch in [Feature #11138]

I'm unsure if ":nonblock" is a good keyword to use, since it is
somewhat confusing


---Files--------------------------------
0002-socket-accept_nonblock-supports-nonblock-false-kwarg.patch (2.94 KB)


-- 
https://bugs.ruby-lang.org/