Skip to content

Instantly share code, notes, and snippets.

@rdp
Created August 16, 2010 21:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdp/527750 to your computer and use it in GitHub Desktop.
Save rdp/527750 to your computer and use it in GitHub Desktop.
require 'socket'
host, port = 'localhost', 7000
TCPServer.open(host, port) do |server|
while client = server.accept
readfds = true
got = nil
begin
readfds, writefds, exceptfds = select([client], nil, nil, 0.1)
p :r => readfds, :w => writefds, :e => exceptfds
if readfds
got = client.gets
p got
end
end until !got
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment