Class: EventMachine::EvmaUNIXClient

Inherits:
StreamObject show all
Defined in:
lib/em/pure_ruby.rb

Instance Attribute Summary

Attributes inherited from Selectable

#io, #is_server, #uuid

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StreamObject

#eventable_read, #get_outbound_data_size, #get_peername, #get_sockname, #heartbeat, #send_data

Methods inherited from Selectable

#close_scheduled?, #get_peername, #get_sockname, #heartbeat, #schedule_close, #set_inactivity_timeout

Constructor Details

#initialize(io) ⇒ EvmaUNIXClient

Returns a new instance of EvmaUNIXClient



1002
1003
1004
1005
# File 'lib/em/pure_ruby.rb', line 1002

def initialize io
  super
  @pending = true
end

Class Method Details

.connect(chain) ⇒ Object



990
991
992
993
994
995
996
997
998
999
# File 'lib/em/pure_ruby.rb', line 990

def self.connect chain
  sd = Socket.new( Socket::AF_LOCAL, Socket::SOCK_STREAM, 0 )
  begin
    # TODO, this assumes a current Ruby snapshot.
    # We need to degrade to a nonblocking connect otherwise.
    sd.connect_nonblock( Socket.pack_sockaddr_un( chain ))
  rescue Errno::EINPROGRESS
  end
  EvmaUNIXClient.new sd
end

Instance Method Details

#eventable_writeObject



1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
# File 'lib/em/pure_ruby.rb', line 1016

def eventable_write
  if @pending
    @pending = false
    if 0 == io.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR).unpack("i").first
      EventMachine::event_callback uuid, ConnectionCompleted, ""
    end
  else
    super
  end
end

#select_for_reading?Boolean

Returns:

  • (Boolean)


1012
1013
1014
# File 'lib/em/pure_ruby.rb', line 1012

def select_for_reading?
  @pending ? false : super
end

#select_for_writing?Boolean

Returns:

  • (Boolean)


1008
1009
1010
# File 'lib/em/pure_ruby.rb', line 1008

def select_for_writing?
  @pending ? true : super
end