class EventMachine::EvmaTCPClient
@private
Public Class Methods
connect(bind_addr, bind_port, host, port)
click to toggle source
# File lib/em/pure_ruby.rb, line 898 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 # TODO, this assumes a current Ruby snapshot. # We need to degrade to a nonblocking connect otherwise. sd.connect_nonblock( Socket.pack_sockaddr_in( port, host )) rescue Errno::ECONNREFUSED, Errno::EINPROGRESS end EvmaTCPClient.new sd end
new(io)
click to toggle source
Calls superclass method
EventMachine::StreamObject.new
# File lib/em/pure_ruby.rb, line 911 def initialize io super @pending = true @handshake_complete = false end
Public Instance Methods
handshake_complete?()
click to toggle source
# File lib/em/pure_ruby.rb, line 925 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?()
click to toggle source
# File lib/em/pure_ruby.rb, line 938 def pending? handshake_complete? if @pending if ready? @pending = false EventMachine::event_callback uuid, ConnectionCompleted, "" end end @pending end
ready?()
click to toggle source
# File lib/em/pure_ruby.rb, line 917 def ready? if RUBY_PLATFORM =~ /linux/ io.getsockopt(Socket::SOL_TCP, Socket::TCP_INFO).unpack("i").first == 1 # TCP_ESTABLISHED else io.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR).unpack("i").first == 0 # NO ERROR end end
select_for_reading?()
click to toggle source
Calls superclass method
EventMachine::StreamObject#select_for_reading?
# File lib/em/pure_ruby.rb, line 954 def select_for_reading? pending? super end
select_for_writing?()
click to toggle source
Calls superclass method
EventMachine::StreamObject#select_for_writing?
# File lib/em/pure_ruby.rb, line 949 def select_for_writing? pending? super end