Class: Socket

Inherits:
Object
  • Object
show all
Defined in:
lib/midori/core_ext/socket.rb

Instance Method Summary collapse

Instance Method Details

#reuse_portObject



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

def reuse_port
  setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEPORT, 1)
  true
rescue => _e
  false
end

#tcp_fast_openObject



2
3
4
5
6
7
8
9
10
# File 'lib/midori/core_ext/socket.rb', line 2

def tcp_fast_open
  # macOS devices option is DIFFERENT from Linux and FreeBSD
  opt = (/darwin/ =~ RUBY_PLATFORM) ? 1 : 5
  # Magic number 6 may refer to Socket::SOL_TCP or Socket::IPPROTO_TCP
  setsockopt(6, Socket::TCP_FASTOPEN, opt)
  true
rescue => _e
  false
end