Module: Hatetepe::Connection

Included in:
Client, Server
Defined in:
lib/hatetepe/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#processing_enabledObject Also known as: processing_enabled?

Returns the value of attribute processing_enabled.



3
4
5
# File 'lib/hatetepe/connection.rb', line 3

def processing_enabled
  @processing_enabled
end

Instance Method Details

#close_connection(after_writing = false) ⇒ Object



46
47
48
49
# File 'lib/hatetepe/connection.rb', line 46

def close_connection(after_writing = false)
  @closed_by = :self unless closed?
  super
end

#closed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/hatetepe/connection.rb', line 26

def closed?
  !!defined?(@closed_by)
end

#closed_by_connect_timeout?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/hatetepe/connection.rb', line 42

def closed_by_connect_timeout?
  !connected? && @closed_by == :timeout
end

#closed_by_remote?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/hatetepe/connection.rb', line 30

def closed_by_remote?
  @closed_by == :remote
end

#closed_by_self?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/hatetepe/connection.rb', line 34

def closed_by_self?
  @closed_by == :self
end

#closed_by_timeout?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/hatetepe/connection.rb', line 38

def closed_by_timeout?
  connected? && @closed_by == :timeout
end

#comm_inactivity_timeout=(seconds) ⇒ Object



61
62
63
64
65
# File 'lib/hatetepe/connection.rb', line 61

def comm_inactivity_timeout=(seconds)
  unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
    super
  end
end

#connected?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/hatetepe/connection.rb', line 22

def connected?
  defined?(@connected) && @connected
end

#connection_completedObject



18
19
20
# File 'lib/hatetepe/connection.rb', line 18

def connection_completed
  @connected = true
end

#pending_connect_timeout=(seconds) ⇒ Object



67
68
69
70
71
# File 'lib/hatetepe/connection.rb', line 67

def pending_connect_timeout=(seconds)
  unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
    super
  end
end

#remote_addressObject



6
7
8
# File 'lib/hatetepe/connection.rb', line 6

def remote_address
  sockaddr && sockaddr[1]
end

#remote_portObject



10
11
12
# File 'lib/hatetepe/connection.rb', line 10

def remote_port
  sockaddr && sockaddr[0]
end

#sockaddrObject



14
15
16
# File 'lib/hatetepe/connection.rb', line 14

def sockaddr
  @sockaddr ||= Socket.unpack_sockaddr_in(get_peername) rescue nil
end

#unbind(reason) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/hatetepe/connection.rb', line 51

def unbind(reason)
  unless closed?
    @closed_by = if reason == Errno::ETIMEDOUT
      :timeout
    else
      :remote
    end
  end
end