Class: Rev::Socket

Inherits:
IO
  • Object
show all
Defined in:
lib/rev/socket.rb

Direct Known Subclasses

TCPSocket, UNIXSocket

Defined Under Namespace

Classes: Connector

Constant Summary

Constants inherited from IO

IO::INPUT_SIZE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IO

#attached?, #close, #closed?, #detach, #disable, #enable, #enabled?, #evloop, #initialize, #on_close, #on_read, #on_write_complete, #output_buffer_size, #write

Methods included from Meta

#event_callback, #watcher_delegate

Constructor Details

This class inherits a constructor from Rev::IO

Class Method Details

.connect(socket, *args) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/rev/socket.rb', line 12

def self.connect(socket, *args)

  new(socket, *args).instance_eval do
    @_connector = Connector.new(self, socket)
    self
  end
end

Instance Method Details

#attach(evloop) ⇒ Object

Raises:

  • (RuntimeError)


22
23
24
25
26
27
28
29
30
31
# File 'lib/rev/socket.rb', line 22

def attach(evloop)
  raise RuntimeError, "connection failed" if @_failed
  
  if @_connector
    @_connector.attach(evloop)
    return self
  end
  
  super
end

#on_connectObject

Called upon completion of a socket connection



34
# File 'lib/rev/socket.rb', line 34

def on_connect; end

#on_connect_failedObject

Called if a socket connection failed to complete



38
# File 'lib/rev/socket.rb', line 38

def on_connect_failed; end

#on_resolve_failedObject

Called if a hostname failed to resolve when connecting Defaults to calling on_connect_failed



43
44
45
# File 'lib/rev/socket.rb', line 43

def on_resolve_failed
   on_connect_failed
end