Newer
Older
Ruby / tuusinn.rb
# coding: utf-8
require 'socket'

# サーバ接続 OPEN
sock = TCPSocket.open("localhost", 20000)

while line = $stdin.gets
  # ソケットに入力文字列を渡す
  sock.puts line
  sock.flush

  # サーバから返却された文字列を出力
  puts sock.gets
end

# ソケット CLOSE
sock.close