Skip to content

Instantly share code, notes, and snippets.

@bararchy
Created June 1, 2015 17:33
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 bararchy/6735bf9e1c59914c929a to your computer and use it in GitHub Desktop.
Save bararchy/6735bf9e1c59914c929a to your computer and use it in GitHub Desktop.
## 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