Created
March 30, 2015 07:04
-
-
Save komasaru/64286f9c6a4f57e57204 to your computer and use it in GitHub Desktop.
Ruby script to test for socket connection.(Client-side)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/ruby | |
# coding: utf-8 | |
#******************************************************** | |
# Ruby script to test for socket connection.(Client-side) | |
#******************************************************** | |
# | |
require 'socket' | |
# サーバ接続 OPEN | |
sock = TCPSocket.open("localhost", 20000) | |
while line = $stdin.gets | |
# ソケットに入力文字列を渡す | |
sock.puts line | |
sock.flush | |
# サーバから返却された文字列を出力 | |
puts sock.gets | |
end | |
# ソケット CLOSE | |
sock.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment