Client vs. Servers
Clients are general-purpose computers; whereas, servers are usually designed for specific purposes. For example, your computer can send and receive emails, play games, browse the internet and more, hence having a general purpose. An email server is designed to only process and relay emails, and nothing else.
DNS: Domain Name System
A server is just like a computer, located somewhere in the world. We know that houses have addresses. On the other hand, a server also has an address in which we call the Internet Protocol Address (IP Address), i.e. 192.168.0.1. Servers from Google, Facebook and Amazon all have IP addresses. But, these IP addresses (like 192.168.0.1) are not particularly easy to remember. They also have no semantic meanings. For example, One World Trade Center is located at 285 Fulton St, New York, NY 10007, which people can understand because of its semantic meanings. However, One World Trade Center is also located at 40° 42' 28.07" N, -74° 00' 29.16" W (GPS coordinates), carrying no semnatic meanings.
To bring semantic meanings to IP addresses on the internet, we have developed a more user friendly way of expression – Uniform Resource Locators (URLs), where you can use a URL (i.e. https://www.google.com) to represent an IP address. For example, https://www.google.com will now represent 192.168.0.1. This way, people can buy domain names (usually with semantic meanings) for better user experiences. Companies can buy domain names that represent their brands.
There are millions of domain names in the world. To map www.google.com to 192.168.0.1, there needs to be a system to map each domain name to its corresponding IP address. Such system needs to recognize a domain name like www.google.com and eventually point you to the exact address of the corresponding server. The system is called the Domain Name System (DNS).
DNS can be quickly updated. For example, Google's domain www.google.com was initially mapped to its server with an IP address 192.168.0.1. Now, Google decided to use another server with an IP address 192.168.0.2. The DNS can be quickly updated to map www.google.com to 192.168.0.2 instead, all of which will not affect the end users. The end users will continue use Google with the domain name www.google.com without noticing the IP address change beneath.
IPv6
Since we now have so many servers, the original IP addresses are running out of space. So, we upgraded the system to include more digits, hence allowing more unique addresses.
IPv4 stands for Internet Protocol version 4. It is the underlying technology that makes it possible for us to connect our devices to the web. Whenever a device access the Internet (whether it's a PC, Mac, smartphone or other device), it is assigned a unique, numerical IP address such as 99.48.227.227
IPv6 is the sixth revision to the Internet Protocol and the successor to IPv4. It functions similarly to IPv4 in that it provides the unique, numerical IP addresses necessary for Internet-enabled devices to communicate. However, it does sport one major difference: it utilizes 128-bit addresses like 2606:2800:220:6d:26bf:1447:1097:aa7
.
Request and Response
The backbone of the internet is helping millions manage information. It can deliver information, help you store information. It also helps you update and delete information. The flow almost always goes like this:
- You (being the client) sends a request to a server
- The server processes your request
- The server sends back a response corresponding to your request
You always need to send a request if you want to get something done on the internet (and in life). After that, you would normally expect a response. Unlike in life, you can expect servers to always get back to you with a response, even if the response is a rejection.
So, what kind of requests can I send anyways?
TCP/IP, HTTP
Clients and servers on the internet communicate with each other using a set of protocols called TCP/IP.
Internet Protocol (optional read)
The Internet Protocol (IP) is the principal communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet.
IP has the task of delivering packets from the source host to the destination host solely based on the IP addresses in the packet headers. For this purpose, IP defines packet structures that encapsulate the data to be delivered. It also defines addressing methods that are used to label the datagram with source and destination information.
Transmission Control Protocol (optional read)
TCP (Transmission Control Protocol) provides reliable, ordered, and error-checked delivery of a stream of octets between applications running on hosts communicating over an IP network. TCP is the protocol that major Internet applications such as the World Wide Web, email, remote administration and file transfer rely on.
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. This is a convenient model. You could say that TCP provides an abstraction of the network.
Hypertext Transfer Protocol (optional read)
The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web. Hypertext is structured text that uses logical links (hyperlinks) between nodes containing text. HTTP is the protocol to exchange or transfer hypertext.
To add content to the Web, all you need to do is connect a machine to the Internet, and have it listen on port 80, using the Hypertext Transfer Protocol (HTTP). This protocol allows other computers to request documents over the network.
Each document on the Web is named by a Uniform Resource Locator (URL), which looks something like this:
http://hackpacific.com/backendium
| | | |
protocol server path
When you type the above address into your browser's address bar. The browser will first find IP address of the server of hackpacific.com
through the Domain Name System.
It then tries to open a TCP connection on port 80 with the server
80 is the default port for HTTP traffic.
If the connection is successful, the browser will send a request to the server.
authority: www.hackpacific.com
method: GET
path: /backendium
scheme: https
Hack Pacific uses HTTPs instead of HTTP which is a more secure encrypted version of HTTP. That's why the scheme says
https
.
If everything goes well, the server will respond with:
Status Code: 200 OK
content-type: text/html; charset=utf-8
<!DOCTYPE html>
... Rest of document
The HTML document was sent back with the response, and your browser will render it. Normally, when we want to get something from a server, we would use the GET
request. There is also DELETE
for deleting, PUT
for replacing, and POST
for sending information.
The server responded with a status code 200
which means OK. Status codes that begin with a 2 means successful request. Codes that start with 4 mean the request had error. 404
means the resource requested could not be found. Codes that begin with 5 mean the server had an error while processing the request but the request was fine.