The SocketHandler is the default query handler provided with the Whois library. It performs the WHOIS query using a synchronous socket connection.
Array of connection errors to rescue and wrap into a {Whois::ConnectionError}
Performs the Socket request.
@todo *args might probably be a Hash.
@param [String] query @param [Array] args @return [String]
# File lib/whois/server/socket_handler.rb, line 37 def call(query, *args) execute(query, *args) rescue *RESCUABLE_CONNECTION_ERRORS => error raise ConnectionError, "#{error.class}: #{error.message}" end
Executes the low-level Socket connection.
It opens the socket passing given args, sends the query and reads the response.
@param [String] query @param [Array] args @return [String]
@api private
# File lib/whois/server/socket_handler.rb, line 54 def execute(query, *args) client = TCPSocket.new(*args) client.write("#{query}\r\n") # I could use put(foo) and forget the \n client.read # but write/read is more symmetric than puts/read ensure # and I really want to use read instead of gets. client.close if client # If != client something went wrong. end
Generated with the Darkfish Rdoc Generator 2.