Method: RTunnel::SocketFactory.set_options

Defined in:
lib/rtunnel/socket_factory.rb

.set_options(socket, options) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/rtunnel/socket_factory.rb', line 73

def self.set_options(socket, options)
  if options[:no_delay]
    socket.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true
    socket.sync = true
  end
  
  if options[:reuse_addr]
    socket.setsockopt Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true
  end
  
  unless options[:reverse_lookup]
    if socket.respond_to? :do_not_reverse_lookup
      socket.do_not_reverse_lookup = true
    else
      # work around until the patch below actually gets committed:
      # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/2346
      BasicSocket.do_not_reverse_lookup = true
    end
  end
end