Class: Rev::Socket::Connector
- Defined in:
- lib/rev/socket.rb
Instance Method Summary collapse
-
#initialize(rev_socket, ruby_socket) ⇒ Connector
constructor
A new instance of Connector.
- #on_writable ⇒ Object
Methods inherited from IOWatcher
#attach, #detach, #disable, #enable, #on_readable
Methods included from Meta
#event_callback, #watcher_delegate
Methods inherited from Watcher
#attach, #attached?, #detach, #disable, #enable, #enabled?, #evloop
Constructor Details
#initialize(rev_socket, ruby_socket) ⇒ Connector
Returns a new instance of Connector.
52 53 54 55 |
# File 'lib/rev/socket.rb', line 52 def initialize(rev_socket, ruby_socket) @rev_socket, @ruby_socket = rev_socket, ruby_socket super(ruby_socket, :w) end |
Instance Method Details
#on_writable ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rev/socket.rb', line 57 def on_writable evl = evloop detach if connect_successful? @rev_socket.instance_eval { @_connector = nil } @rev_socket.attach(evl) @ruby_socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, [1].pack("l")) @ruby_socket.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_KEEPALIVE, true) @rev_socket.__send__(:on_connect) else @rev_socket.instance_eval { @_failed = true } @rev_socket.__send__(:on_connect_failed) end end |