Class: Dalli::Server::KSocket
- Inherits:
-
Socket
- Object
- Socket
- Dalli::Server::KSocket
- Defined in:
- lib/dalli/socket.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
2 3 4 |
# File 'lib/dalli/socket.rb', line 2 def @options end |
Class Method Details
.open(host, port, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dalli/socket.rb', line 4 def self.open(host, port, = {}) # All this ugly code to ensure proper Socket connect timeout addr = Socket.getaddrinfo(host, nil) sock = new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0) sock. = { :host => host, :port => port }.merge() begin sock.connect_nonblock(Socket.pack_sockaddr_in(port, addr[0][3])) rescue Errno::EINPROGRESS resp = IO.select(nil, [sock], nil, sock.[:timeout]) begin sock.connect_nonblock(Socket.pack_sockaddr_in(port, addr[0][3])) rescue Errno::EISCONN end end sock end |
Instance Method Details
#readfull(count) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dalli/socket.rb', line 21 def readfull(count) value = '' begin loop do value << sysread(count - value.bytesize) break if value.bytesize == count end rescue Errno::EAGAIN, Errno::EWOULDBLOCK if IO.select([self], nil, nil, [:timeout]) retry else raise Timeout::Error, "IO timeout: #{.inspect}" end end value end |