Class: EventMachine::EvmaTCPClient
Instance Attribute Summary
Attributes inherited from Selectable
#io, #uuid
Class Method Summary
collapse
Instance Method Summary
collapse
#eventable_read, #get_outbound_data_size, #get_peername, #heartbeat, #schedule_close, #send_data
Methods inherited from Selectable
#close_scheduled?, #get_peername, #heartbeat, #set_inactivity_timeout
Constructor Details
Returns a new instance of EvmaTCPClient.
661
662
663
664
|
# File 'lib/pr_eventmachine.rb', line 661
def initialize io
super
@pending = true
end
|
Class Method Details
.connect(host, port, bind_host = nil) ⇒ Object
648
649
650
651
652
653
654
655
656
657
658
|
# File 'lib/pr_eventmachine.rb', line 648
def self.connect host, port, bind_host = nil
sd = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 )
sd.bind(Socket.pack_sockaddr_in(0, bind_host)) if bind_host
begin
sd.connect_nonblock( Socket.pack_sockaddr_in( port, host ))
rescue Errno::EINPROGRESS
end
EvmaTCPClient.new sd
end
|
Instance Method Details
#eventable_write ⇒ Object
675
676
677
678
679
680
681
682
683
684
|
# File 'lib/pr_eventmachine.rb', line 675
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
671
672
673
|
# File 'lib/pr_eventmachine.rb', line 671
def select_for_reading?
@pending ? false : super
end
|
#select_for_writing? ⇒ Boolean
667
668
669
|
# File 'lib/pr_eventmachine.rb', line 667
def select_for_writing?
@pending ? true : super
end
|