rework sendAndRecv and related so it can handle shutdown connections