From a44a538ac6c77283ea7588c9ffa8d2699269373f Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Tue, 25 Jan 2011 13:28:51 +0100 Subject: [PATCH] added a test echo client --- echo_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 echo_test.rb diff --git a/echo_test.rb b/echo_test.rb new file mode 100644 index 0000000..e884391 --- /dev/null +++ b/echo_test.rb @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby -wKU + +require 'socket' # Sockets are in standard library + +hostname = 'localhost' +port = 7000 + +s = TCPSocket.open(hostname, port) + +print "What to echo? " +q = gets +s.print(q) + +while true + line = s.gets # Read lines from the socket + puts "Got Echo: " + line.chop # And print with platform line terminator +end +s.close # Close the socket when done \ No newline at end of file