socket: handle hangup after input but before output
Merge pull request #97 from mtomaschewski/socket-in-hup-order

socket: handle hangup after input but before output