Network (Internet | World Wide Web)

Connecting cables between two or more computers and allow them to send data back and forth through these cables; connecting machines shooting bits at each other all over the planet, the network is called internet.

For effective communications, computers on both ends must know what the bits represent. Its style is called network protocol. There are protocols for sending & fetching email, for sharing files, and even for controlling computers that happen to be infected by malicious software.

All Internet-connected devices “speak” Transmission Control Protocol (TCP), and most communication on the Internet is built on top of it.

A TCP connection works as follows:

  • One computer must be waiting, or listening, for other computers to start talking to it.
    • To be able to listen for different kinds of communication at the same time on a single machine, each listener has a number (called a port) associated with it.
    • Most protocols specify which port should be used by default. For example, when we want to send an email using the SMTP protocol, the machine through which we send it is expected to be listening on port 25.
  • Another computer can then establish a connection by connecting to the target machine using the correct port number.
    • If the target machine can be reached and is listening on that port, the connection is successfully created.
    • The listening computer is called the server, and the connecting computer is called the client.
      • Such a connection acts as a two-way pipe through which bits can flow—the machines on both ends can put data into it.
      •  Once the bits are successfully transmitted, they can be read out again by the machine on the other side.

World Wide Web (not the Internet) is a set of protocols and formats that allow us to visit web pages in a browser.

  • To become part of the Web,
    • connect a machine to the Internet
    • have it listen on port 80 with the HTTP protocol
  • so that other computers can ask it for documents.

Machines connected to the Internet get an IP address, which is a number that can be used to send messages to that machine, and looks something like or 2001:4860:4860::8888.

You can register a domain name to point at the IP address of a machine you control.

Each document on the Web is named by a Uniform Resource Locator (URL), e.g.:
ProtocolDomain Name Server (document’s location)Path (of the requested document)

If you type this URL into your browser’s address bar, the browser will try to retrieve and display the document at that URL.

  • First, your browser has to find out what address refers to.
  • Then, using the HTTP protocol, it will make a connection to the server at that address and ask for the resource /13_browser.html.
  • If all goes well, server sends back document, your browser then displays on your screen.

The Hypertext Transfer Protocol (HTTP) retrieves named resources (chunks of information, such as web pages or pictures).

  • It specifies that the side making the request start with naming the resource and the version of the protocol that it is trying to use: GET /index.html HTTP/1.1
  •  HTTP treats the network as a streamlike device into which you can put bits and have them arrive at the correct destination in the correct order.

Isolating a programming environment to test is called sandboxing, the idea being that the program is harmlessly playing in a sandbox.

When you open a web page in your browser, the browser retrieves the page’s HTML text and parses it.

  • The browser builds up a Document Object Model (DOM) of the document’s structure and uses this model to draw the page on the screen.
  • This representation of the document is one of the toys that a JavaScript program has available in its sandbox that acts as a live data structure: when it’s modified, the page on the screen is updated to reflect the changes.
<!doctype html> <html>                 <head>                                 <title>My home page</title>                 </head>                 <body>                                 <h1>My home page</h1>                                 <p>Hello, I am Marijn and this is my home page.</p>                                 <p>                                                 I also wrote a book! Read it                                                 <a href=””>here</a>.                                 </p>                 </body> </html>

With JavaScript, almost everything about the DOM data structure can be changed.


  1. M., Haverbeke. (2014). Eloquent JavaScript: A Modern Introduction to Programming. S.l.: No Starch Press,US.