added a test echo client
This commit is contained in:
parent
719aa36b03
commit
a44a538ac6
1 changed files with 18 additions and 0 deletions
18
echo_test.rb
Normal file
18
echo_test.rb
Normal file
|
@ -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
|
Reference in a new issue