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.
666
667
668
669
|
# File 'lib/pr_eventmachine.rb', line 666
def initialize io
super
@pending = true
end
|
Class Method Details
.connect(bind_addr, bind_port, host, port) ⇒ Object
652
653
654
655
656
657
658
659
660
661
662
663
|
# File 'lib/pr_eventmachine.rb', line 652
def self.connect bind_addr, bind_port, host, port
sd = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 )
sd.bind( Socket.pack_sockaddr_in( bind_port, bind_addr )) if bind_addr
begin
sd.connect_nonblock( Socket.pack_sockaddr_in( port, host ))
rescue Errno::EINPROGRESS
end
EvmaTCPClient.new sd
end
|
Instance Method Details
#eventable_write ⇒ Object
680
681
682
683
684
685
686
687
688
689
|
# File 'lib/pr_eventmachine.rb', line 680
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
676
677
678
|
# File 'lib/pr_eventmachine.rb', line 676
def select_for_reading?
@pending ? false : super
end
|
#select_for_writing? ⇒ Boolean
672
673
674
|
# File 'lib/pr_eventmachine.rb', line 672
def select_for_writing?
@pending ? true : super
end
|