From 36de27e6798f8c41b4bbbdca887cbcf000ed6490 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Wed, 13 May 2015 18:07:40 +0200 Subject: feed.rb --- feed.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 feed.rb (limited to 'feed.rb') diff --git a/feed.rb b/feed.rb new file mode 100755 index 00000000..58e3f78b --- /dev/null +++ b/feed.rb @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby + +require 'nanomsg' + +port = 8888 +sock = NanoMsg::PairSocket.new +addr = "tcp://127.0.0.1:#{port}" +sock.connect addr +puts 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 + -- cgit v1.2.3 From 5b000aa1d539a4c31449c4ccaf15e8ca91bf90ba Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Wed, 27 May 2015 19:20:00 +0200 Subject: net: feed.rb with opts --- feed.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'feed.rb') diff --git a/feed.rb b/feed.rb index 58e3f78b..a925d31c 100755 --- a/feed.rb +++ b/feed.rb @@ -1,12 +1,16 @@ #!/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 -port = 8888 sock = NanoMsg::PairSocket.new -addr = "tcp://127.0.0.1:#{port}" +addr = conf[:addr] sock.connect addr -puts sock.recv +puts "< got #{sock.recv}" while true line = STDIN.gets -- cgit v1.2.3