modified server method to flush data streams before attempting to send over a socket