Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby script to test for socket connection.(Client-side)
#! /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
You can’t perform that action at this time.