Skip to content

Instantly share code, notes, and snippets.

Created June 8, 2016 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4c957a4ee8a7577b841adfe6e82bab09 to your computer and use it in GitHub Desktop.
Save anonymous/4c957a4ee8a7577b841adfe6e82bab09 to your computer and use it in GitHub Desktop.
require 'socket' # Sockets are in standard library
require 'prime'
hostname = '131.246.19.102'
port = 1337
s = TCPSocket.open(hostname, port)
# Read lines from the socket
puts s.gets.chop# And print with platform line terminator
s.send "1#399308\r\n" , 0
#399308
puts s.gets.chop
s.send "2#vladvozniuc96@gmail.com\r\n" ,0
#vladvozniuc96@gmail.com
puts s.gets.chop
#now start game
s.send "12\r\n" , 0
@now = 0
@last = 0
while true
@now = s.gets.chop
if s.gets == "" # do this in case of no respod form server after X time!!!!
puts "server" + @now + "\r\n"
s.send "12##{@now[3..5].to_i}\r\n" , 0
puts "client" + @now + "\r\n"
else
puts "server is an asshole\r\n"
s.send "12##{@last[3..5].to_i}\r\n" , 0
puts "client" + @last + "\r\n"
end
@last = @now
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment