Created
June 1, 2015 17:33
-
-
Save bararchy/6735bf9e1c59914c929a to your computer and use it in GitHub Desktop.
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
## Former code which works: | |
Thread.new(server.accept) do |client| | |
if client | |
addr = client.peeraddr if client | |
log.info("Client connected from IP: #{addr.ip_address} and port: #{addr.ip_port}") if log && addr | |
package_parser(client, log) | |
client.close if client | |
end | |
end | |
## New code which dosn't work: | |
server.accept do |client| | |
spawn do | |
if client | |
s_c = client | |
if s_c | |
addr = s_c.peeraddr if s_c | |
log.info("Client connected from IP: #{addr.ip_address} and port: #{addr.ip_port}") if log && addr | |
package_parser(s_c, log) | |
s_c.close if s_c | |
end | |
end | |
end | |
end | |
end | |
## What dosent work ? now I get errors like this: | |
Unhandeled Exception: getpeername: Bad file descriptor | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment