Lecture

Contributors: Alicia Wang, Conner Swenberg

Lecture Slides

12MB
lecture1.pdf
pdf

Clients

Clients are the computers we use everyday, including phones, tablets, laptops, desktops, and gaming consoles. Clients run code locally on their machine. Things like rendering images, reacting to button clicks and user input are all done as part of the frontend of an application. What makes an application truly “networked”, i.e. involving actions from other clients, is the backend of the application. These backends exist in the cloud, running on servers.

Servers

Servers are also computers, just like clients. Servers centralize information and run backend code to execute operations to data and communicate with clients. This is the Server-Client Model and it is how the internet is architected today. Independent machines (like a phone, computer, etc.) make requests to servers and use the data returned in responses.

Requests

Requests are the network calls transferred over the web. Let’s dissect a request made to http://www.google.com:

http: Hyper Text Transfer Protocol defines the protocol for the request and is reserved for port 80 on servers. HTTP requests can be made with one of many types of methods. A method indicates the type of request being sent and how to handle the request. The most common methods used are GET, POST, DELETE, PUT, PATCH and are all standardized by HTTP protocol. Methods indicate the purpose of the request. GET is for information retrieval, POST for information transmission, DELETE for deleting, PUT & PATCH both for updating. Requests can also contain metadata, optional information located in the body of the request. Metadata can be in many forms, the two most common are XML and JSON. A request body is likely populating in the case of creating or updating items in the database.

www: The subdomain we are trying to access.

google: The domain we are trying to access. A Domain Name Service (DNS) will map this domain to a specific server for you to communicate with.

Going to http://www.google.com makes a GET request to the google domain. Similarly we can send a POST request to http://www.google.com/login to login our user. In the case of logging in, our POST request’s body will likely contain email/password information to be authenticated on the server.

Responses

Servers respond the exact same way with their own network calls. They also obey HTTP protocol and have the ability to contain metadata in a response body. Responses also contain specific codes giving us a high-level understanding of how the request was handled. Some common examples are:

  • 200 → Successful

  • 404 → Not found

  • 500 → Internal server error (an uncaught exception)

The Whole Process

  1. A client makes a request for specific pieces of data that are sent out over the internet

  2. The request is received by a server

  3. The server runs internal processes to create, retrieve, update, or delete items

  4. The server returns response back to client over the internet

Last updated