Introduction to protocols
Protocols are the rules that specify how messages should be formatted and how responses should be generated.
Protocols are important in programming because they allow devices to communicate with each other.
In order for two devices to communicate, they need to be using the same protocol, the same way that two humans can't understand each other unless they communicate with a shared language.
There are many different protocols that can be used, and each has its own advantages and disadvantages, and each has been heavily influenced by the technology available at the time it was started.
Some common protocols used in programming include TCP/IP, HTTP / HTTPS, and SMTP. Lets learn a bit about the purpose and inner-workings of each of these more-common protocols.
The TCP/IP protocol stack
The TCP/IP protocol stack is a set of protocols that are used to communicate over the internet.
The stack consists of four layers: the physical layer, the data link layer, the network layer, and the transport layer.
Each layer has its own set of protocols that are responsible for different tasks.
The physical layer handles communication between devices, the data link layer handles communication between nodes, the network layer handles routing of packets, and the transport layer handles end-to-end communication.
HTTP and HTTPS protocols
Historically, HTTP is the protocol used to fetch web pages, while HTTPS is used for secure communications, such as online banking or shopping.
But most modern websites use HTTPS to serve traffic on all web pages to ensure all websites are as secure as possible.
Both HTTP and HTTPS use the same underlying technology, but HTTPS adds an extra layer of security by encrypting data before it is transmitted.
When you visit a website, your browser will automatically use whichever protocol is supported by the site (usually HTTPS).
However, you can force your browser to use HTTP if you're visiting an older website. Some websites offer both HTTP and HTTPS versions, while others only offer one or the other.
SMTP is a text-based protocol that uses plain text to send messages (such as email), and is what's called a push protocol, which means that it sends messages from one server to another.
SMTP is also referred to as a store-and-forward protocol, which means that it stores messages on the sending server until they can be delivered to the receiving server.
And SMTP is a "reliable protocol," which means that delivery of messages is guaranteed.
FTP is a standard protocol for transferring files between computers on the Internet, and it's a "client-server protocol", which means that an FTP client program (running on your computer) is used to connect to an FTP server program (running on the remote computer.)
Once connected, you can upload or download files from the server using the FTP client.
To connect to an FTP server, you need the server's hostname or IP address, as well as a username and password (if the server requires authentication.)
There are many different FTP clients available; some are free, while others must be purchased.
As we discussed, protocols are different sets of rules and standards that govern how computer code works, and there's a near-infinite number of them.
Some were created decades ago, while many others were created just within the last year or two (many of the crypto currencies started in the early 2020's created their own protocols.)
Protocols are constantly evolving, so it is important to stay up-to-date on the latest changes.