Just a simple question how does a web browser retrieve a web page? I think that in some way the browser finds out the i.p. address the domain points to and send the request to that server asking for a specific file.

I am only asking this because i want to make a lightweight browser for the Wii since Opera has its limits and c++ is different to php where in php the network is setup for you but in c++ you have to setup the network first(well i think so).

Dani AI

Generated

and are right about the big picture. One nuance: your browser does not talk to the global DNS directly. It asks the OS resolver, which queries a recursive resolver you have configured (often your router/ISP, but it could be a public one). Results are cached at several layers (browser, OS, resolver) until the record TTL expires, so most lookups do not climb the hierarchy every time.

Once a hostname is resolved, the browser opens a TCP connection to the server (HTTP on port 80 or, far more common today, HTTPS on 443). For HTTPS, a TLS handshake happens first; the client sends SNI so the server can choose the right certificate for that hostname. Then the browser sends an HTTP request that must include a Host header (since HTTP/1.1) so name-based virtual hosting works. The server replies with headers and a body. The browser parses the HTML, then issues additional requests for CSS, JS, and images. Persistent connections and pipelining/multiplexing reduce round trips, but a basic client does not need those to start.

For a minimal C++ fetcher (good stepping stone for a Wii build), the wire steps look like this:

// 1) DNS
addrinfo hints{}; hints.ai_socktype = SOCK_STREAM;
addrinfo* res = nullptr;
getaddrinfo("example.com", "80", &hints, &res);

// 2) TCP connect
int fd = socket(res->ai_family, res->ai_socktype, 0);
connect(fd, res->ai_addr, res->ai_addrlen);

// 3) HTTP request
std::string req =
  "GET /path HTTP/1.1\r\n"
  "Host: example.com\r\n"
  "Connection: close\r\n\r\n";
send(fd, req.data(), (int)req.size(), 0);

// 4) Read until EOF
char buf[4096];
int n;
std::string resp;
while ((n = recv(fd, buf, sizeof buf, 0)) > 0) resp.append(buf, n);
close(fd);

Practical gotchas for : many sites force HTTPS, so you will need TLS (do not roll your own; use a small library). Handle redirects (3xx), chunked transfer encoding, and gzip/br content-encoding. Time out your DNS and socket calls, and prefer getaddrinfo over hard-coding IPv4 so your client stays flexible.

Recommended Answers

All 5 Replies

Odds are that you're not going to be able to make a web browser from scratch if you have to ask these specific questions, but here's the info:

When you enter a domain name into a web browser the browser transmits that to your ISPs DNS server. Which works with the global DNS network to find that website. Once the DNS has been resolved it will connect to the web server by IP adress and download the files indicated, then render them into a viewable webpage by loading the primary HTML file and any content referenced (images or client-side includes) that needs to be downloaded from a different location and embedded.

That's the browser end of it, to my understanding.

On the hosting end a server directs traffic by port (HTTP being port 80). When a connection comes in on port 80 it directs it to the HTTP server and the appropriate location (www.example.com will go to /index.html [or whatever the default main page is], where will go to /support/contact.html.) The file at this location is then downloaded to your system and run in your browser.

I don't write software or specialize in DNS, I just configure PCs and servers. So I hope this information is all correct.

thanks for the info, i know about the rendering i just want to know who handles the DNS requests

I'm 99% sure it sends it down the line to your ISP just as you type in (Adding the HTTP:// if you didn't) and then they translate it. DNS is a server side process.

Oly is correct. DNS servers are arranged in a hierarchy (sp) fashion. Your machine sends the request to your router/modem, then it gets forwarded on up the chain of connections to a DNS server. If the DNS server knows what the IP is for the requested domain, it will direct you to the appropriate server. If it doesn't know, it will forward the request higher up to the next DNS server, so on and so fourth.

The web browser contacts the holding server though the internet and access the source with the webpage on receves the html and converts it to a IWP (interactive web page) and then the GWP (Graphical web page) sends it back on your ISP's data source finds your IP and then your ISP (internet service provider ) sends it to you.
that also determinds how fast it will get there depending on the speed of you ISP SPMT rate refering yours and then divide by 5 to give the speed MPH.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.