close socket on exception; better detection of EOF vs. EOB