summaryrefslogtreecommitdiffstats
path: root/sample/clnt.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-19 20:26:16 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-19 20:26:16 +0000
commitf8a5273c820871700563a57acc87ac8bb5e933ae (patch)
tree7482b5a88aed2c13d2f2e45cf8679fc4a1ec9484 /sample/clnt.rb
parent90ebdfb2054ccc506ab6dd9c72882c0332d02393 (diff)
downloadruby-f8a5273c820871700563a57acc87ac8bb5e933ae.tar.gz
ruby-f8a5273c820871700563a57acc87ac8bb5e933ae.tar.xz
ruby-f8a5273c820871700563a57acc87ac8bb5e933ae.zip
Strive to give better examples.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/clnt.rb')
-rw-r--r--sample/clnt.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/sample/clnt.rb b/sample/clnt.rb
index 4f96ca408..0f3d17bf1 100644
--- a/sample/clnt.rb
+++ b/sample/clnt.rb
@@ -3,15 +3,19 @@
require "socket"
-host=(if ARGV.length == 2; ARGV.shift; else "localhost"; end)
+if ARGV.length >= 2
+ host = ARGV.shift
+else
+ host = "localhost"
+end
print("Trying ", host, " ...")
STDOUT.flush
s = TCPSocket.open(host, ARGV.shift)
print(" done\n")
print("addr: ", s.addr.join(":"), "\n")
print("peer: ", s.peeraddr.join(":"), "\n")
-while gets()
- s.write($_)
+while line = gets()
+ s.write(line)
print(s.readline)
end
s.close