Added socket.flush() calls to force data through sockets.