Once a stock is listed, the stocks can be traded by the investors in the secondary market. That is where the primary market ends and the secondary market begins. This is where most of the trading happens. In this market, buyers and sellers gather to conduct transactions to make profits or cut losses. Stockbrokers and brokerage firms are entities registered with the stock exchange. They act as an intermediary between an investor and the stock exchange.
What happens when you place a Buy order? The broker passes on your buy order to the exchange, which searches for a sell order for the same share. Once a seller and a buyer are fixed, a price is agreed finalized, upon which the exchange communicates to your broker that your order has been confirmed. This message is then passed on to you. Even at the broker and exchange levels, there are multiple parties involved in the communication chain like brokerage order department, exchange floor traders, and so on. However, the trading process has become electronic today. This process of matching buyers and sellers is done through computers and you can actually see the process online in front of your eyes.
Now, the settlement process has been brought down to T+2 days. For example, if you conducted a trade today, you will get your shares deposited in your demat account by the day after tomorrow ( i.e. two working days).