module EPPClient::Connection
This handles all the basic I/O for the connection.
Attributes
recv_frame[R]
sent_frame[R]
srv_ext[R]
srv_lang[R]
srv_ns[R]
srv_version[R]
Public Instance Methods
close_connection()
click to toggle source
Gracefully close the connection
# File lib/epp-client/connection.rb, line 34 def close_connection if defined?(@socket) && @socket.is_a?(OpenSSL::SSL::SSLSocket) @socket.close @socket = nil end if defined?(@tcpserver) && @tcpserver.is_a?(TCPSocket) @tcpserver.close @tcpserver = nil end return true if @tcpserver.nil? && @socket.nil? end
one_frame()
click to toggle source
gets a frame from the socket and returns the parsed response.
# File lib/epp-client/connection.rb, line 62 def one_frame size = @socket.read(4) raise SocketError, @socket.eof? ? 'Connection closed by remote server' : 'Error reading frame from remote server' if size.nil? size = size.unpack('N')[0] @recv_frame = @socket.read(size - 4) recv_frame_to_xml end
open_connection()
click to toggle source
Establishes the connection to the server, if successful, will return the greeting frame.
# File lib/epp-client/connection.rb, line 8 def open_connection @tcpserver = TCPSocket.new(server, port) @socket = OpenSSL::SSL::SSLSocket.new(@tcpserver, @context) # Synchronously close the connection & socket @socket.sync_close # Connect @socket.connect # Get the initial greeting frame greeting_process(one_frame) end
send_frame(xml)
click to toggle source
sends a frame
# File lib/epp-client/connection.rb, line 55 def send_frame(xml) @sent_frame = xml @socket.write([xml.size + 4].pack('N') + xml) sent_frame_to_xml end
send_request(xml)
click to toggle source
Sends a frame and returns the server's answer
# File lib/epp-client/connection.rb, line 49 def send_request(xml) send_frame(xml) one_frame end