Saturday 16 September 2017

Part 1 : Client Server And Protocols

Part 1 : Client and Server


First, lets define Client and Server.

Client: Someone who sends requests is a client. There are majorly two types of requests.
Server: Someone responding to the requests of client is server.
  • GET Request: Client asks for a information or a file.
  • POST Request: Client requests a update in existing data on the server. This request is analogous to edit request.
Image result for client server

Since we know that clients and servers can communicate with each other, but how do we know they're all speaking the same language?

So we need some rules to make sure all machines on the internet are communicating in the same way. These rules are called Protocols.

There are several protocols such as:
  • Transmission Control Protocol : It enables information to be broken in small packets and sent between client and server. If some packets is missing the sender and receiver have ways of figuring out the packets is missing and request that they be resent.
  • User Data gram Protocol : Its good for sending and receiving streaming contents like music and video.
  • Internet Protocol : Similar to postal addresses , IP addresses allows messages to be sent properly.    Every device has a IP address that is statically or dynamically provided by a service provider. When we type google.com in our browser the computer first figures out the IP address of Google by looking it up in big online phone book called  Domain Name Server or DNS that contains IP addresses corresponding to a site name.
There are multiple application running on machine, Operating System use ports to designate channels of communication on the same IP address.

Ports ranges from 0 to 65,536. But ports 0 to 10,000 are reserved by the operating system for specific use. Port 80 and 8080 are the most common ports for web server.

When client and server are on same machine we indicate this with localhost. It has a special IP address 127.0.0.1. So when we type localhost in our browser it transform into a IP address 127.0.0.1 and the operating system knows, it need not to send request over the internet since server is on the same machine.

Status code : This is the server reply to a client as to what happened after a specific request. In addition to status code server can also supply requested resources that client requested like CSS, HTML, JavaScript and media files. Some of the status codes:
  • 200 : Indicates a successful GET request.
  • 301 : Indicates a successful post request.
  • 404 : Indicates that requested file not found in the server.
Next, we will see how to how to create HTTPBaseServer from scratch.

No comments:

Post a Comment