class Redis::Connection::TCPSocket
Public Class Methods
connect(host, port, timeout)
click to toggle source
# File lib/redis/connection/ruby.rb, line 106 def self.connect(host, port, timeout) Timeout.timeout(timeout) do sock = new(host, port) sock end rescue Timeout::Error raise TimeoutError end
connect_addrinfo(addrinfo, port, timeout)
click to toggle source
# File lib/redis/connection/ruby.rb, line 148 def self.connect_addrinfo(addrinfo, port, timeout) sock = new(::Socket.const_get(addrinfo[0]), Socket::SOCK_STREAM, 0) sockaddr = ::Socket.pack_sockaddr_in(port, addrinfo[3]) begin sock.connect_nonblock(sockaddr) rescue Errno::EINPROGRESS raise TimeoutError unless sock.wait_writable(timeout) begin sock.connect_nonblock(sockaddr) rescue Errno::EISCONN end end sock end