Class: Redis::Connection::TCPSocket
- Inherits:
-
Socket
- Object
- Socket
- Redis::Connection::TCPSocket
show all
- Includes:
- SocketMixin
- Defined in:
- lib/redis/connection/ruby.rb,
lib/redis/connection/ruby.rb
Constant Summary
Constants included
from SocketMixin
SocketMixin::CRLF
Class Method Summary
collapse
#_read_from_socket, #_write_to_socket, #gets, #initialize, #read, #timeout=, #write, #write_timeout=
Class Method Details
.connect(host, port, timeout) ⇒ Object
114
115
116
117
118
119
120
121
|
# File 'lib/redis/connection/ruby.rb', line 114
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) ⇒ Object
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/redis/connection/ruby.rb', line 156
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 if IO.select(nil, [sock], nil, timeout).nil?
begin
sock.connect_nonblock(sockaddr)
rescue Errno::EISCONN
end
end
sock
end
|