call socket.shutdown() before socket.close()