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
118
119
120
121
122
123
124
125
|
# File 'lib/redis/connection/ruby.rb', line 118
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/redis/connection/ruby.rb', line 160
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
|