detecting closed socket after send