Class: Async::IO::TCPServer
- Inherits:
-
TCPSocket
- Object
- Wrapper
- Generic
- BasicSocket
- IPSocket
- TCPSocket
- Async::IO::TCPServer
- Includes:
- Server
- Defined in:
- lib/async/io/tcp_socket.rb
Overview
Asynchronous TCP server wrappper.
Constant Summary
Constants inherited from Generic
Instance Attribute Summary
Attributes inherited from TCPSocket
Instance Method Summary collapse
- #accept(task: Task.current) ⇒ Object (also: #accept_nonblock, #sysaccept)
-
#initialize(*args) ⇒ TCPServer
constructor
A new instance of TCPServer.
Methods included from Server
Methods inherited from BasicSocket
Methods inherited from Generic
#nonblock, #nonblock?, #read, #wait, wrap, wrap_blocking_method, wraps, #write
Constructor Details
#initialize(*args) ⇒ TCPServer
Returns a new instance of TCPServer.
65 66 67 68 69 70 71 72 |
# File 'lib/async/io/tcp_socket.rb', line 65 def initialize(*args) if args.first.is_a? ::TCPServer super(args.first) else # We assume this operation doesn't block (for long): super(::TCPServer.new(*args)) end end |
Instance Method Details
#accept(task: Task.current) ⇒ Object Also known as: accept_nonblock, sysaccept
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/async/io/tcp_socket.rb', line 74 def accept(task: Task.current) peer, address = async_send(:accept_nonblock) wrapper = TCPSocket.new(peer) return wrapper, address unless block_given? begin yield wrapper, address ensure wrapper.close end end |