Refactor with blocking IO sockets.