Skip to content

Instantly share code, notes, and snippets.

@grauwoelfchen
Last active January 21, 2016 21:31
Show Gist options
  • Save grauwoelfchen/26dfb3c9548ade69e942 to your computer and use it in GitHub Desktop.
Save grauwoelfchen/26dfb3c9548ade69e942 to your computer and use it in GitHub Desktop.
Client for skkserv (dbskkd-cdb)
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