Class: H2::Client::TCPSocket

Inherits:
Socket
  • Object
show all
Includes:
ExceptionlessIO
Defined in:
lib/h2/client/tcp_socket.rb

Defined Under Namespace

Modules: ExceptionlessIO

Constant Summary collapse

DEFAULT_TIMEOUT =
10

Instance Method Summary collapse

Constructor Details

#initialize(addr, port, timeout = DEFAULT_TIMEOUT) ⇒ TCPSocket

ON_LINUX = !!(RUBY_PLATFORM =~ /linux/)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/h2/client/tcp_socket.rb', line 10

def initialize addr, port, timeout = DEFAULT_TIMEOUT

  # resolve name & pack addr
  family, addr = Socket.getaddrinfo(addr, port, nil, :STREAM, nil, AI_ALL).first.values_at(0,3)
  @_sockaddr = Socket.sockaddr_in port, addr

  super family, SOCK_STREAM

  # allow send before ack
  setsockopt IPPROTO_TCP, TCP_NODELAY, 1

  # cork on linux
  # setsockopt IPPROTO_TCP, TCP_CORK, 1 if ON_LINUX

  handle_wait_writable(timeout){ _connect } if _connect == :wait_writable
end

Instance Method Details

#selectorObject



27
28
29
# File 'lib/h2/client/tcp_socket.rb', line 27

def selector
  @selector ||= [self]
end