Class: OkGntpd
- Inherits:
-
Object
- Object
- OkGntpd
- Defined in:
- lib/ok_gntpd.rb,
lib/ok_gntpd/version.rb
Constant Summary collapse
- VERSION =
"0.0.5"
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ OkGntpd
constructor
A new instance of OkGntpd.
- #start ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ OkGntpd
Returns a new instance of OkGntpd.
18 19 20 21 |
# File 'lib/ok_gntpd.rb', line 18 def initialize( = nil) @options = self.class..merge( || {}) @status = :stop end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/ok_gntpd.rb', line 16 def @options end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
16 17 18 |
# File 'lib/ok_gntpd.rb', line 16 def status @status end |
Class Method Details
.default_options ⇒ Object
10 11 12 13 14 |
# File 'lib/ok_gntpd.rb', line 10 def self. { :port => 23053 } end |
.start(options = nil) ⇒ Object
6 7 8 |
# File 'lib/ok_gntpd.rb', line 6 def self.start( = nil) new().start end |
Instance Method Details
#start ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ok_gntpd.rb', line 23 def start port = @options[:port] puts "Start listening GNTP on #{port}." gate = TCPServer.open(port) begin @status = :start loop do sock = gate.accept sock.write <<EOS GNTP/1.0 -OK NONE\r \r EOS sock.close end ensure gate.close @status = :stop puts "Closed." end end |