Method: TCPSocket#read_nonblock

Defined in:
lib/polyphony/extensions/socket.rb

#read_nonblock(maxlen, buf = nil, exception: true) ⇒ String, :wait_readable

Performs a non-blocking read from the socket of up to maxlen bytes. If buf is given, it is used as the read buffer, otherwise a new string will be allocated. If the socket is not ready for reading and exception is true, an IO::WaitReadable will be raised. If the socket is not ready for reading and exception is false, :wait_readable is returned.

Parameters:

  • maxlen (Integer)

    maximum bytes to read

  • buf (String, nil) (defaults to: nil)

    read buffer

  • exception (bool) (defaults to: true)

    whether to raise an exception if not ready for reading

Returns:

  • (String, :wait_readable)

    read buffer



426
427
428
# File 'lib/polyphony/extensions/socket.rb', line 426

def read_nonblock(maxlen, buf = nil, exception: true)
  @io.read_nonblock(maxlen, buf, exception:)
end