Handle socket.write return value.

The method socket.write can return false and in that case the amqp client messes up the shared buffer. We can just allocate a new buffer when that happens.