Skip to content

Instantly share code, notes, and snippets.

@datanoise
Last active August 29, 2015 14:22
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 datanoise/6ee434ed397f4e74bfbd to your computer and use it in GitHub Desktop.
Save datanoise/6ee434ed397f4e74bfbd to your computer and use it in GitHub Desktop.
require "socket"
class AeonClient
def self.main
alter_aeon_server = "alteraeon.com"
alter_aeon_port = 3000
connection = TCPSocket.new(alter_aeon_server, alter_aeon_port)
spawn autoreader(connection)
Signal::INT.trap do
puts "Exiting.."
connection.close
end
until connection.closed?
buff = gets
connection << buff.to_s if connection
end
end
def self.autoreader(connection)
until connection.closed?
buf :: UInt8[4096]
len = connection.read(buf.to_slice)
if len > 0
data = String.new(buf.buffer, len)
print data if !data.empty?
else
connection.close
break
end
end
end
end
AeonClient.main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment