Method: Socketry::TCP::Socket#write_nonblock

Defined in:
lib/socketry/tcp/socket.rb

#write_nonblock(data) ⇒ Fixnum, :wait_writable

Perform a non-blocking write operation

Parameters:

  • data (String)

    data to write to the socket

Returns:

  • (Fixnum, :wait_writable)

    number of bytes written, or :wait_writable if op would block

Raises:



224
225
226
227
228
229
230
231
232
# File 'lib/socketry/tcp/socket.rb', line 224

def write_nonblock(data)
  ensure_connected
  @socket.write_nonblock(data, exception: false)
rescue IO::WaitWriteable
  # Some buggy Rubies continue to raise this exception
  :wait_writable
rescue IOError => ex
  raise Socketry::Error, ex.message, ex.backtrace
end