class KQueue::Watcher::SocketReadWrite

The {Watcher} subclass for events fired when a socket can be read from or written to (which of these is determined by {ReadWrite#type}). Read events are watched via {Queue#watch_socket_for_read}, and write events are watched via {Queue#watch_socket_for_write}.

Note that read and write events for non-socket streams use the {ReadWrite} class.

Attributes

low_water[R]

The custom low-water mark for the amount of data necessary to trigger an event, or `nil` if none has been set.

@return [Fixnum, nil]

Public Class Methods

new(queue, fd, type, low_water, callback) click to toggle source

Creates a new socket Watcher.

@private

Calls superclass method KQueue::Watcher::ReadWrite.new
# File lib/rb-kqueue/watcher/socket_read_write.rb, line 22
def initialize(queue, fd, type, low_water, callback)
  if fd.is_a?(IO)
    @io = fd
    fd = fd.fileno
  end

  @fd = fd
  @type = type

  if low_water
    fflags = [:lowat]
    data = low_water
  else
    fflags = []
    data = nil
  end

  super(queue, @fd, type, fflags, data, callback)
end