Q:

Where do the ethers come from when sending ethers with .send() function in ethereum contract

I'm learning ethereum token contract following here. I'm confused by the code below:
function sell(uint amount) returns (uint revenue){
if (balanceOf[msg.sender] < amount ) throw;        // checks if the sender has enough to sell
balanceOf[this] += amount;                         // adds the amount to owner's balance
balanceOf[msg.sender] -= amount;                   // subtracts the amount from seller's balance
revenue = amount * sellPrice;
if (!msg.sender.send(revenue)) {                   // sends ether to the seller: it's important
    throw;                                         // to do this last to prevent recursion attacks
} else {
    Transfer(msg.sender, this, amount);             // executes an event reflecting on the change
    return revenue;                                 // ends function and returns
}

}
the line msg.sender.send(revenue) means to send ethers to the seller. My question is:
Does the ethers to be sent come from msg.sender or from the token contract?
I think they comes from msg.sender. However the msg.sender is actually in behalf of the seller, right? That makes the seller sends himself ethers. May I know how to understand this. And then how do I make a contract send ethers back to a user account automatically?
Thanks!

A:

I did some tests to figure out this question. I find out that the ethers which are sent to destination address are from the token contract instance address.
I was confused before because I didn't understand how a contract instance gains ethers after being constructed. Now I get to know that the contract instance gains ethers when an account invokes a method marked by keyword payable of the contract. When the invoking happens the ethers are sent to the contract address at the meantime. In the demo token code, it is the method buy() who plays the role to send ethers to the contract address.
I'm new for learning ethereum contract. There probably still are some mistakes about what I realize. Please let me know if there are. Appreciate that!
Thanks!

