Last active
August 29, 2015 14:22
This file contains hidden or 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" | |
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