Class: Moped::Connection::TCPSocket Private
- Defined in:
- lib/moped/connection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This is a wrapper around a tcp socket.
Class Method Summary collapse
-
.connect(host, port, timeout) ⇒ TCPSocket
private
Connect to the tcp server.
Instance Method Summary collapse
-
#alive? ⇒ true, false
private
Is the socket connection alive?.
-
#write(*args) ⇒ Integer
private
Write to the socket.
Class Method Details
.connect(host, port, timeout) ⇒ TCPSocket
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Connect to the tcp server.
190 191 192 193 194 195 196 197 |
# File 'lib/moped/connection.rb', line 190 def connect(host, port, timeout) Timeout::timeout(timeout) do sock = new(host, port) sock.set_encoding('binary') sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) sock end end |
Instance Method Details
#alive? ⇒ true, false
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Is the socket connection alive?
153 154 155 156 157 158 159 |
# File 'lib/moped/connection.rb', line 153 def alive? if Kernel::select([ self ], nil, nil, 0) !eof? rescue false else true end end |
#write(*args) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Write to the socket.
171 172 173 174 |
# File 'lib/moped/connection.rb', line 171 def write(*args) raise Errors::ConnectionFailure, "Socket connection was closed by remote host" unless alive? super end |