Last active
January 21, 2016 21:31
-
-
Save grauwoelfchen/26dfb3c9548ade69e942 to your computer and use it in GitHub Desktop.
Client for skkserv (dbskkd-cdb)
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
require 'socket' | |
require 'thread' | |
socket = TCPSocket.open('127.0.0.1', 1178) | |
socket.set_encoding('EUC-JP') | |
# Response | |
thread = Thread.new do | |
while line = socket.gets | |
line.split.each do |l| | |
puts l.encode('UTF-8') | |
end | |
end | |
end | |
# Requests | |
# CLIENT_VERSION | |
socket.write("2 \n") | |
sleep 0.3 | |
# CLIENT_HOST | |
# dummyhostname: https://github.com/jj1bdx/dbskkd-cdb/blob/master/dbskkd-cdb.c#L126 | |
socket.write("3 \n") | |
sleep 0.3 | |
# CLIENT_REQUEST | |
socket.write("1/し \n") | |
sleep 0.3 | |
socket.write("1/しあ \n") | |
sleep 0.3 | |
# CLIENT_END | |
socket.write("0 \n") | |
thread.join | |
socket.close | |
require 'socket' | |
require 'thread' | |
socket = TCPSocket.open('127.0.0.1', 1178) | |
socket.set_encoding('EUC-JP') | |
# Response | |
thread = Thread.new do | |
while line = socket.gets | |
line.split.each do |l| | |
puts l.encode('UTF-8') | |
end | |
end | |
end | |
# Requests | |
# CLIENT_VERSION | |
socket.write("2 \n") | |
sleep 0.3 | |
# CLIENT_HOST | |
# dummyhostname: https://github.com/jj1bdx/dbskkd-cdb/blob/master/dbskkd-cdb.c#L126 | |
socket.write("3 \n") | |
sleep 0.3 | |
# CLIENT_REQUEST | |
socket.write("1/し \n") | |
sleep 0.3 | |
socket.write("1/しあ \n") | |
sleep 0.3 | |
# CLIENT_END | |
socket.write("0 \n") | |
thread.join | |
socket.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment