summaryrefslogtreecommitdiff
path: root/feed.rb
blob: a925d31c9c47de577317ca90e10937459e165945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env ruby

require 'nanomsg'
require 'trollop'

conf = Trollop::options do
  opt :addr, "URL of socket", :type => :string, :short => '-a', :default => "tcp://127.0.0.1:31337"
end

sock = NanoMsg::PairSocket.new
addr = conf[:addr]
sock.connect addr
puts "< got #{sock.recv}"

while true
  line = STDIN.gets
  if !line || line.strip=='shutdown'
    puts "shutting down"
    sock.send 'shutdown'
    break
  end
  puts "sending '#{line.strip}'"
  sock.send line.strip
  sleep 1
  puts "got response '#{sock.recv}'"
end