Module: Socket::ListenAndAccept
- Includes:
- IO::Socketable
- Included in:
- Socket, TCPServer, UNIXServer
- Defined in:
- lib/rubysl/socket/socket.rb
Instance Method Summary collapse
- #accept ⇒ Object
-
#accept_nonblock ⇒ Object
Set nonblocking and accept.
- #accept_nonblock2 ⇒ Object
- #listen(backlog) ⇒ Object
Instance Method Details
#accept ⇒ Object
453 454 455 456 457 458 459 460 461 |
# File 'lib/rubysl/socket/socket.rb', line 453 def accept return if closed? fd = super socket = self.class.superclass.allocate IO.setup socket, fd, nil, true socket end |
#accept_nonblock ⇒ Object
Set nonblocking and accept.
466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/rubysl/socket/socket.rb', line 466 def accept_nonblock return if closed? fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK) fd = Socket::Foreign.accept descriptor, nil, nil Errno.handle 'accept(2)' if fd < 0 # TCPServer -> TCPSocket etc. *sigh* socket = self.class.superclass.allocate IO.setup socket, fd, nil, true socket end |
#accept_nonblock2 ⇒ Object
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/rubysl/socket/socket.rb', line 481 def accept_nonblock2 return if closed? fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK) fd = Socket::Foreign.accept descriptor, nil, nil if fd < 0 return nil if FFI::Platform::POSIX.errno == Errno::EAGAIN::Errno Errno.handle 'accept(2)' end # TCPServer -> TCPSocket etc. *sigh* socket = self.class.superclass.allocate IO.setup socket, fd, nil, true socket end |