Created
August 17, 2012 08:52
-
-
Save asanghi/3377119 to your computer and use it in GitHub Desktop.
Celluloid IO connection handler
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
def read_until_eot(socket) | |
eot_found = false | |
message = '' | |
begin | |
message += socket.read() | |
eot_found = message['\004'].present? # <-- ughh what can i do? | |
end until eot_found | |
message | |
end | |
def handle_connection(socket) | |
# read from socket until EOT | |
message = read_until_eot(socket) # <-- need help with | |
if parse(message) #message can be parsed | |
# process message | |
output = process(message) | |
end | |
# write to socket | |
socket.write output_message | |
# close socket | |
socket.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment