Git Product home page Git Product logo

lectures-east-22-07-06's Introduction

Networking with HTTP and TCP

Computer networking refers to interconnected computing devices that can exchange data and share resources with each other. Essentially two or multiple devices communicating with one another.

We have rules or protocols set in place, so that the exchange of information goes smoothly and there isn't any lost information. If there is, then there is a protocol in place to fix it.

  • There is always one listening(client) and another sending(server) information. But the roles aren't fixed, they can change.

OSI (Open Systems Interconnection Model)

There are 7 layers in OSI(Refer to image OSI.webp)

  • 1 - Physical (Ethernet / USB / IEEE1394)
  • 2 - Datalink Layer (WiFi / ARP / MAC / PPP)
  • 3 - Network (IP / NAT / ARP)
  • 4 - Transport (TCP / UDP / FCP)
  • 5 - Session (TCP* / SMB / NetBEUI)
  • 6 - Presentation (TLS / SSL / GZIP)
  • 7 - Application (HTTP / SMTP / SSH)

The ones we focused the most on were 1,2,3,4,5. These don't have to be memorized, as the OSI model isn't used, however it helps when debuggin networking issues in code.

TCP/UDP

Both are in transport layer. They set protocols on how data is transfered from client to server.

  • Messages are broken down into packets
  • Messages contained source and destination address in their header
  • Each packet travels through the network independently
  • Packets are reassembled into a full message when reaching destination
  • TCP ensures that there are no lost packages.(No miscommunication)
  • UDP is a connectionless protocol, it will continue the communication even if there is a lost package.(Live streaming websites)

A great example of TCP is the chat server, which was built using NET. Use telnet in another terminal to connect to the server. If the port is 3000, you would run

telnet localhost 3000

What is HTTP ?

HyperText Transfer Protocol - a protocol that deals with the transmission of hypermedia(HTML, JPEGs, etc.) It is apart of the 7th layer of OSI.

How a web client (browser, etc) communicates with a web server

The initial step of an HTTP exchange is the request. In the request, we want to make an action, decided by the method, to a specific path, the URL, with specific headers and an optional body content.

In httpRequest.js, we can see what information we can get out of a http request, by using the node package Request. To run the code please install the package by running

npm install

A request will return information about the header, the body, and a response code for the request made.

Response Status

More information regarding status codes

  • 100 series - Informational responses
  • 200 series - Successful responses
  • 300 series - Redirection messages
  • 400 series - Client error messages
  • 500 series - Server error messages

lectures-east-22-07-06's People

Contributors

senhorgomes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.