Class: TCPTimeoutSocket
- Inherits:
-
Object
show all
- Defined in:
- lib/active_support/vendor/memcache-client-1.6.5/memcache.rb
Overview
TCPSocket facade class which implements timeouts.
Instance Method Summary
collapse
Constructor Details
#initialize(host, port, timeout) ⇒ TCPTimeoutSocket
Returns a new instance of TCPTimeoutSocket.
856
857
858
859
860
861
|
# File 'lib/active_support/vendor/memcache-client-1.6.5/memcache.rb', line 856
def initialize(host, port, timeout)
Timeout::timeout(MemCache::Server::CONNECT_TIMEOUT, SocketError) do
@sock = TCPSocket.new(host, port)
@len = timeout
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
885
886
887
|
# File 'lib/active_support/vendor/memcache-client-1.6.5/memcache.rb', line 885
def method_missing(meth, *args)
@sock.__send__(meth, *args)
end
|
Instance Method Details
881
882
883
|
# File 'lib/active_support/vendor/memcache-client-1.6.5/memcache.rb', line 881
def _socket
@sock
end
|
893
894
895
|
# File 'lib/active_support/vendor/memcache-client-1.6.5/memcache.rb', line 893
def close
@sock.close
end
|
#closed? ⇒ Boolean
889
890
891
|
# File 'lib/active_support/vendor/memcache-client-1.6.5/memcache.rb', line 889
def closed?
@sock.closed?
end
|
#gets(*args) ⇒ Object
869
870
871
872
873
|
# File 'lib/active_support/vendor/memcache-client-1.6.5/memcache.rb', line 869
def gets(*args)
Timeout::timeout(@len, SocketError) do
@sock.gets(*args)
end
end
|
#read(*args) ⇒ Object
875
876
877
878
879
|
# File 'lib/active_support/vendor/memcache-client-1.6.5/memcache.rb', line 875
def read(*args)
Timeout::timeout(@len, SocketError) do
@sock.read(*args)
end
end
|
#write(*args) ⇒ Object
863
864
865
866
867
|
# File 'lib/active_support/vendor/memcache-client-1.6.5/memcache.rb', line 863
def write(*args)
Timeout::timeout(@len, SocketError) do
@sock.write(*args)
end
end
|