How Apache name-based virtual host works with public IP address?

view story

http://serverfault.com – I am new to Apache web server. When we configure Apache web server, we have the options of setting name-based virtual host. Based on my understanding, when a user type in a domain name www.example.com in a web browser, it will connect to a DNS server which will convert the domain name to a (public) IP address. Then, the web browser will connect to the web server using the IP address. Now, let's say I have a server with a public IP address, a.a.a.a. I have registered 2 domain names, www.example.com and www.example1.com. Both of these 2 domain names are pointing to the same IP address, a.a.a.a (HowTos)