* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git] / sample / clnt.rb
blob0f3d17bf19e769e945ae166a4a3dd98a8d20ab5c
1 # socket example - client side
2 # usage: ruby clnt.rb [host] port
4 require "socket"
6 if ARGV.length >= 2
7   host = ARGV.shift
8 else
9   host = "localhost"
10 end
11 print("Trying ", host, " ...")
12 STDOUT.flush
13 s = TCPSocket.open(host, ARGV.shift)
14 print(" done\n")
15 print("addr: ", s.addr.join(":"), "\n")
16 print("peer: ", s.peeraddr.join(":"), "\n")
17 while line = gets()
18   s.write(line)
19   print(s.readline)
20 end
21 s.close