added new exception for socket failures so that we dont prematurely give up on this pair (using a different WZ might solve the problem). also added flushing after all outputs so that the logs will better reflect the current state.
added flushing to the server too, but only after connection is closed, so that it doesnt inflate the time before a response