in reply to unblocking sockets

Check out Event::Lib, which is a wrapper around libevent. This will really make your non-blocking IO programming a breeze.