How to use Threads and Sockets in Ruby