Module: TcpUserTimeout::Hook::SocketTcp

Defined in:
lib/tcp_user_timeout/hook.rb

Instance Method Summary collapse

Instance Method Details

#tcp(host, port, *args, **kwargs, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tcp_user_timeout/hook.rb', line 13

def tcp(host, port, *args, **kwargs, &block)
  if block
    super(host, port, *args, **kwargs) do |sock|
      TcpUserTimeout.maybe_apply!(sock)
      block.call(sock)
    end
  else
    sock = super(host, port, *args, **kwargs)
    TcpUserTimeout.maybe_apply!(sock)
    sock
  end
end