Method: Socketry::TCP::Socket#read_nonblock
- Defined in:
- lib/socketry/tcp/socket.rb
#read_nonblock(size, outbuf: nil) ⇒ String, :wait_readable
Perform a non-blocking read operation
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/socketry/tcp/socket.rb', line 151 def read_nonblock(size, outbuf: nil) ensure_connected case outbuf when String @socket.read_nonblock(size, outbuf, exception: false) when NilClass @socket.read_nonblock(size, exception: false) else raise TypeError, "unexpected outbuf class: #{outbuf.class}" end rescue IO::WaitReadable # Some buggy Rubies continue to raise this exception :wait_readable rescue IOError => ex raise Socketry::Error, ex., ex.backtrace end |