# work0803.rb
# 入出力クライアント
# キーボード入力があれば、それをサーバに送り、
# サーバから返信があれば、それを画面に表示する。
require 'socket'
hostname = Socket::gethostname
port = 3456
cs = TCPSocket.open(hostname,port)
flag = true
while flag do
inputs = IO.select([$stdin,cs])
if inputs != nil
if inputs[0][0] == $stdin
if $stdin.eof?
flag = false
else
cs.puts $stdin.gets.chomp
end
else
puts cs.gets.chomp
end
end
end
cs.close