Class: EventMachine::EvmaTCPClient
Instance Attribute Summary
Attributes inherited from Selectable
#io, #is_server, #uuid
Class Method Summary
collapse
Instance Method Summary
collapse
#eventable_read, #eventable_write, #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
Returns a new instance of EvmaTCPClient.
929
930
931
932
933
|
# File 'lib/em/pure_ruby.rb', line 929
def initialize io
super
@pending = true
@handshake_complete = false
end
|
Class Method Details
.connect(bind_addr, bind_port, host, port) ⇒ Object
916
917
918
919
920
921
922
923
924
925
926
927
|
# File 'lib/em/pure_ruby.rb', line 916
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::ECONNREFUSED, Errno::EINPROGRESS
end
EvmaTCPClient.new sd
end
|
Instance Method Details
#handshake_complete? ⇒ Boolean
943
944
945
946
947
948
949
950
951
952
953
954
|
# File 'lib/em/pure_ruby.rb', line 943
def handshake_complete?
if !@handshake_complete && io.respond_to?(:state)
if io.state =~ /^SSLOK/
@handshake_complete = true
EventMachine::event_callback uuid, SslHandshakeCompleted, ""
EventMachine::event_callback uuid, SslVerify, io.peer_cert.to_pem if io.peer_cert
end
else
@handshake_complete = true
end
@handshake_complete
end
|
#pending? ⇒ Boolean
956
957
958
959
960
961
962
963
964
965
|
# File 'lib/em/pure_ruby.rb', line 956
def pending?
handshake_complete?
if @pending
if ready?
@pending = false
EventMachine::event_callback uuid, ConnectionCompleted, ""
end
end
@pending
end
|
#ready? ⇒ Boolean
935
936
937
938
939
940
941
|
# File 'lib/em/pure_ruby.rb', line 935
def ready?
if RUBY_PLATFORM =~ /linux/
io.getsockopt(Socket::SOL_TCP, Socket::TCP_INFO).unpack("i").first == 1 else
io.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR).unpack("i").first == 0 end
end
|
#select_for_reading? ⇒ Boolean
972
973
974
975
|
# File 'lib/em/pure_ruby.rb', line 972
def select_for_reading?
pending?
super
end
|
#select_for_writing? ⇒ Boolean
967
968
969
970
|
# File 'lib/em/pure_ruby.rb', line 967
def select_for_writing?
pending?
super
end
|