aboutsummaryrefslogtreecommitdiffstats
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
commitd46e835344bc4d43c804d7b2d66145b80ef0c7e3 (patch)
tree7482b5a88aed2c13d2f2e45cf8679fc4a1ec9484 /sample/clnt.rb
parentc3cd615aa4a2e52d8943df72a9a55d2607792fe9 (diff)
downloadruby-d46e835344bc4d43c804d7b2d66145b80ef0c7e3.tar.gz
Strive to give better examples.
git-svn-id: svn+ssh://ci.ruby-lang.org/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 4f96ca4089..0f3d17bf19 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