Vast majority of the time it works like this:
Total commission is paid by seller based the sales price at closing. Here in Texas the rate is usually 6%.Let's say the sales price is $500,000, so the commission is 6% x $500,000 = $30,000
$30,000 then is shared (typically 50/50) between listing agent (meaning the agent represents the seller) and the selling agent (meaning the agent represents the buyer). So each agent gets $15,000.
Hope this helps.