Class: MelissaData::Server::TCP

Inherits:
Base
  • Object
show all
Defined in:
lib/melissadata/server/tcp.rb

Instance Attribute Summary

Attributes inherited from Base

#server

Instance Method Summary collapse

Methods inherited from Base

#address_object, #data, #email_object, #geo_object, #initialize, #input, #ip_object, #name_object, #phone_object, #process, #process_address, #process_email, #process_geo, #process_ip, #process_name, #process_phone, #setup, #version

Constructor Details

This class inherits a constructor from MelissaData::Server::Base

Instance Method Details

#run(host = MelissaData::DEFAULT_TCP_ADDRESS, port = MelissaData::DEFAULT_TCP_PORT) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/melissadata/server/tcp.rb', line 4

def run(host=MelissaData::DEFAULT_TCP_ADDRESS, port=MelissaData::DEFAULT_TCP_PORT)
  trap("INT")  { self.stop }
  trap("TERM") { self.stop }

  server.listen(host, port, self)

  puts "== MelissaData TCP server is now listening on #{host}:#{port}"
  server.run
end

#stopObject



14
15
16
17
# File 'lib/melissadata/server/tcp.rb', line 14

def stop
  puts "== Stopping MelissaData TCP server"
  server.stop
end