Class: UNIXServer
Instance Method Summary collapse
-
#accept_nonblock(exception: true) ⇒ Object
call-seq: unixserver.accept_nonblock() => unixsocket.
Instance Method Details
#accept_nonblock(exception: true) ⇒ Object
call-seq:
unixserver.accept_nonblock([]) => unixsocket
Accepts an incoming connection using accept(2) after O_NONBLOCK is set for the underlying file descriptor. It returns an accepted UNIXSocket for the incoming connection.
Example
require ‘socket’ serv = UNIXServer.new(“/tmp/sock”) begin # emulate blocking accept sock = serv.accept_nonblock rescue IO::WaitReadable, Errno::EINTR IO.select() retry end # sock is an accepted socket.
Refer to Socket#accept for the exceptions that may be thrown if the call to UNIXServer#accept_nonblock fails.
UNIXServer#accept_nonblock may raise any error corresponding to accept(2) failure, including Errno::EWOULDBLOCK.
If the exception is Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::ECONNABORTED or Errno::EPROTO, it is extended by IO::WaitReadable. So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock.
By specifying ‘exception: false`, the options hash allows you to indicate that accept_nonblock should not raise an IO::WaitReadable exception, but return the symbol :wait_readable instead.
See
-
UNIXServer#accept
-
Socket#accept
1347 1348 1349 |
# File 'lib/framework/_socket.rb', line 1347 def accept_nonblock(exception: true) __accept_nonblock(exception) end |