How to handle network I/O with ruby