codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Subjects
🌐

Computer Networks

26 chapters

1Network Topologies & LAN/WAN2Network Devices (Hub, Switch, Router)3OSI Reference Model4OSI Model & TCP/IP Suite5TCP/IP Protocol Suite6Switching Techniques (Circuit, Packet)7Data Link: Framing & Error Detection8Error Correction (Hamming Code)9Flow Control (Stop-and-Wait, Sliding Window)10MAC: CSMA/CD & CSMA/CA11Network Layer & Routing12IP Addressing (IPv4, IPv6)13Subnetting & CIDR14Routing Algorithms (Distance Vector, Link State)15ARP, ICMP, and NAT16DHCP Protocol17Transport Layer Services18Transport Layer: UDP19Transport Layer: TCP & 3-Way Handshake20TCP Congestion Control21Application Layer: DNS & HTTP22Application Layer: SMTP & FTP23Socket Programming Basics24Wireless Networks & Wi-Fi Standards25VLANs & Spanning Tree Protocol26Network Security & Cryptography
SubjectsComputer Networks

Application Layer: SMTP & FTP

Updated 2026-05-06
3 min read

Application Layer: SMTP & FTP

While HTTP dominates the modern web, other specialized application layer protocols are responsible for crucial Internet services, specifically email communication and bulk file transfers.

1. SMTP (Simple Mail Transfer Protocol)

SMTP is the absolute standard protocol used for sending electronic mail (email) across the Internet.

It is important to understand that SMTP is a push protocol. It is only used to send emails from a client to a server, or to relay emails between different servers across the globe. You cannot use SMTP to pull (download) an email from a server into your inbox.

How Email Works:

  1. Sending (SMTP): You open Gmail, write an email to bob@yahoo.com, and hit Send. Your mail client uses SMTP (typically over TCP Port 587 or 465) to push the message to Google's Mail Transfer Agent (MTA).
  2. Relaying (SMTP): Google's MTA queries DNS to find the Mail Exchanger (MX) record for yahoo.com. It then establishes an SMTP connection directly to Yahoo's server and pushes the email there.
  3. Receiving (IMAP / POP3): The email sits on Yahoo's server. When Bob opens his Yahoo Mail app, his app uses a pull protocol like IMAP or POP3 to download the email from the server to his phone.

SMTP Commands

SMTP is a text-based protocol. A typical conversation looks like this:

  • HELO gmail.com (Identifying the sender)
  • MAIL FROM: <alice@gmail.com>
  • RCPT TO: <bob@yahoo.com>
  • DATA (Begins the actual email body and subject headers)
  • QUIT (Ends the connection)

2. FTP (File Transfer Protocol)

Before HTTP was capable of handling large file downloads reliably, FTP was the standard mechanism for transferring files between a client and a server on a computer network.

The Dual-Connection Architecture

Unlike HTTP, which uses a single TCP connection for both commands and data, FTP is unique because it uses two separate TCP connections simultaneously:

  1. Control Connection (Port 21): The client establishes a connection to Port 21. This connection is used exclusively for sending commands (like USER, PASS, LIST, RETR) and receiving text responses. This connection remains open for the entire duration of the session.
  2. Data Connection (Port 20): Whenever the client requests a file download or a directory listing, a completely new, temporary TCP connection is established specifically to stream that raw binary data. Once the file transfer is complete, the data connection is instantly closed.

Active vs. Passive Mode

  • Active Mode: The client opens a random port for the data connection, tells the server the port number via the Control Connection, and then the server initiates the Data Connection back to the client. This frequently fails today because modern client firewalls and NAT routers block incoming connection requests.
  • Passive Mode (PASV): To solve the firewall problem, the client asks the server to open a random port. The server tells the client the port number, and the client initiates the Data Connection to the server.

Security Warning: Like standard HTTP, traditional FTP sends everything—including your username and password—in plain text. It is highly insecure. Modern systems use SFTP (SSH File Transfer Protocol), which runs entirely over a secure, encrypted SSH tunnel.



PreviousApplication Layer: DNS & HTTPNextSocket Programming Basics

Recommended Gear

Application Layer: DNS & HTTPSocket Programming Basics