Internet Client Programming
By
[Link] Sampath
What is an Internet Client?
An internet client is a software application that enables a user to access and interact with services
and resources available on the internet. It acts as an intermediary between the user and the server,
sending requests to the server and displaying the received responses in a user-friendly format. In
essence, it's the tool we use to navigate and utilize the vast resources of the internet.
Types of Internet Clients
•Web Browsers: These are the most ubiquitous type of internet client, used for accessing and displaying web
pages. Examples include Chrome, Firefox, Safari, and Edge. They interpret HTML, CSS, and JavaScript to
render websites and allow users to interact with them.
•Email Clients: These applications are used for sending, receiving, and managing emails. Examples include
Outlook, Thunderbird, and Apple Mail. They communicate with email servers using protocols like SMTP, POP3,
and IMAP.
•FTP Clients: File Transfer Protocol (FTP) clients are used for transferring files between a computer and an
FTP server. They are commonly used for uploading and downloading files to and from websites. Examples
include FileZilla and Cyberduck.
•Instant Messaging Clients: These clients facilitate real-time text, voice, and video communication between
users. Examples include WhatsApp, Telegram, and Signal. They use proprietary protocols or open standards
like XMPP to connect to messaging servers.
•Download Managers: These applications are designed to manage and accelerate the downloading of files
from the internet. They can pause and resume downloads, split files into multiple segments for faster
downloading, and schedule downloads for later. Examples include Internet Download Manager (IDM) and Free
Download Manager (FDM).
•Streaming Clients: These clients are used for streaming audio and video content from the internet. Examples
include Spotify, Netflix, and YouTube apps. They use protocols like HTTP Live Streaming (HLS) and Dynamic
Adaptive Streaming over HTTP (DASH) to deliver content.
•Gaming Clients: Many online games require dedicated client software to connect to game servers and
participate in multiplayer gameplay. Examples include the Steam client, the Epic Games Launcher, and various
game-specific clients.
Key Functionalities of Internet Clients
•Request Handling: Clients formulate and send requests to servers based on user input or application
logic. These requests specify the desired resource or action.
•Response Processing: Clients receive responses from servers, parse the data, and present it to the user
in a meaningful way. This may involve rendering HTML, displaying images, playing audio, or executing
JavaScript code.
•Protocol Support: Clients support various internet protocols, such as HTTP, HTTPS, FTP, SMTP, POP3,
IMAP, and others, to communicate with different types of servers.
•Data Management: Clients may store data locally, such as cookies, cached files, and user settings, to
improve performance and personalize the user experience.
•User Interface: Clients provide a user-friendly interface for interacting with the internet, including
navigation tools, search bars, and content display areas.
•Security Features: Clients incorporate security features to protect users from online threats, such as
phishing attacks, malware, and data breaches. These features may include SSL/TLS encryption, anti-
phishing filters, and malware scanners.
What Is FTP?
➢ FTP stands for File Transfer
Protocol.
➢ This communication protocol is
used for file exchange between a
server and a client.
➢ FTP is useful for transferring files
between computers, either
remotely or within a local network
— your personal computer can
even act as an FTP server.
➢ FTP can also be used to upload
files from a computer to a web
hosting account.
➢ The protocol was first developed in 1971 by Abhay Bhushan Pandey, a student at the Massachusetts
Institute of Technology.
➢ FTP has since undergone several revisions in attempts to make it more secure.
➢ Now, there are at least three variations of the protocol — we’ll talk about them in more detail in the
following sections.
How does FTP works?
➢ FTP is built on a client-server model architecture. The protocol uses separate control (command)
and data connections between the client and the server.
➢ The control connection is always the first connection established with an FTP server. Its ultimate
purpose is to enable clients to connect and send commands to the server as well as receive
server responses.
➢ The second type of connection is called the data connection. This is the channel through which
an FTP server exchanges file listings and transfers files. When a client uses the control
connection to “ask” an FTP server to transfer a file, this channel sends the said file.
➢ The default ports for FTP (port 21 for the command connection and port 20 for the data
connection) are standardized and widely used, so it is generally recommended to use these
ports for FTP.
➢ A client establishes a connection to the FTP server by requesting the server’s IP address
and port number. The server responds with a message indicating that the connection has
been established.
➢ The client authenticates with the server by providing a username and password. If the
authentication is successful, the server grants access to the client. Sometimes,
anonymous access is also possible.
➢ The client can then issue FTP commands, such as upload, download, delete, or list files,
to the server.
➢ For file transfers, the client opens a separate data connection to the server. The data
connection transfers the actual file contents between the client and the server.
➢ When the file transfer is complete, the data connection is closed. The client then can
issue further FTP commands or disconnect from the server.
➢ In active mode, the client lets the
server know which destination port
should be used for the data connection.
➢ In passive mode, the server “tells” the
client which server-side port they
should connect to, and the client
initiates the connection.
➢ By default, most FTP clients use active
mode FTP, but they also often have the
option to use passive mode FTP.
➢ Passive mode FTP avoids connectivity
issues caused by client-side firewalls,
allowing the client to initiate the data
connection.
➢ No secret knowledge is needed. FTP is a straightforward protocol that is easy to set up and
use. FTP clients, such as FileZilla, provide a user-friendly interface for transferring files.
➢ FTP is a well-established protocol that has been around for decades. It is supported by
most operating systems and FTP clients.
➢ The protocol is well-suited for local networks/intranet.
➢ FTP is optimized for transferring large files and can transfer data at high speeds — which is
great for uploading large files all at once. Technically, there’s no limit on the file size.
➢ The protocol is a good choice for transferring non-sensitive data.
➢ FTP can be used in scripts or scheduled tasks to automate the transfer of files between
systems. You can pause or resume your transfers.
➢ FTP does not encrypt data transmitted over the network, making it vulnerable to third-party
interception.
➢ Without an FTP client, it can be tricky to keep track of your FTP file transfers.
➢ FTP uses separate control and data connections between the client and server, which can be
inefficient and may not scale well to large numbers of simultaneous connections.
➢ PCI DSS compliance requirements can force you to abandon standard FTP due to security
concerns.
➢ FTP requires a dedicated server to host the transferred files, which can be an additional
financial burden for its users
Python ftplib Module
Definition and Usage
The ftplib module implements the client side of the FTP protocol.
Use it to connect to FTP servers, list directories, and transfer files. For secure
transfers, consider external libraries like ftps or sftp clients.
Member Description
FTP Main FTP client class.
FTP_TLS FTP client class with TLS support.
error_perm Exception for permanent errors.
error_temp Exception for temporary errors.
all_errors Tuple grouping all ftplib exceptions.
# Import Module # Import Module
import ftplib import ftplib
# Fill Required Information # Fill Required Information
HOSTNAME = "[Link]" HOSTNAME = "[Link]"
USERNAME = "dlpuser@[Link]" USERNAME = "dlpuser@[Link]"
PASSWORD = "eUj8GeW55SvYaswqUyDSm5v6N" PASSWORD = "eUj8GeW55SvYaswqUyDSm5v6N"
# Connect FTP Server # Connect FTP Server
ftp_server = [Link](HOSTNAME, USERNAME, ftp_server = [Link](HOSTNAME, USERNAME, PASSWORD)
PASSWORD) # force UTF-8 encoding
# force UTF-8 encoding ftp_server.encoding = "utf-8"
ftp_server.encoding = "utf-8" # Enter File Name with Extension
filename = "[Link]"
# Enter File Name with Extension # Write file in binary mode
filename = "File Name" with open(filename, "wb") as file:
# Read file in binary mode # Command for Downloading the file "RETR filename"
with open(filename, "rb") as file: ftp_server.retrbinary(f"RETR {filename}", [Link])
# Command for Uploading the file "STOR # Get list of files
filename" ftp_server.dir()
ftp_server.storbinary(f"STOR {filename}", file) # Display the content of downloaded file
# Get list of files file= open(filename, "r")
ftp_server.dir() print('File Content:', [Link]())
# Close the Connection # Close the Connection
ftp_server.quit() ftp_server.quit()
Underlying Technologies
•TCP/IP: The Transmission Control Protocol/Internet Protocol (TCP/IP) is the fundamental communication
protocol suite of the internet. It provides reliable, ordered, and error-checked delivery of data between clients and
servers.
•HTTP/HTTPS: The Hypertext Transfer Protocol (HTTP) is used for transferring web pages and other resources
over the internet. HTTPS is the secure version of HTTP, using SSL/TLS encryption to protect data in transit.
•DNS: The Domain Name System (DNS) translates human-readable domain names (e.g., [Link]) into IP
addresses, which are used to locate servers on the internet.
•HTML/CSS/JavaScript: These are the core technologies used for building web pages. HTML defines the
structure and content of a web page, CSS styles the appearance, and JavaScript adds interactivity and dynamic
behavior.
•SSL/TLS: Secure Sockets Layer (SSL) and Transport Layer Security (TLS) are cryptographic protocols that
provide secure communication over the internet. They are used to encrypt data transmitted between clients and
servers, protecting it from eavesdropping and tampering.
Network News (NNTP) Modules
Network News Transfer Protocol (NNTP) is an application protocol used for transporting Usenet news
articles between news servers and from news servers to end-user client applications.
Functionality
•Connecting to a News Server: Establishing a connection to an NNTP server using its hostname and
port.
•Authentication: Providing credentials (username and password) to access restricted newsgroups.
•Listing Newsgroups: Retrieving a list of available newsgroups from the server.
•Selecting a Newsgroup: Choosing a specific newsgroup to read articles from.
•Retrieving Article Headers: Fetching the headers of articles within a newsgroup.
•Retrieving Article Bodies: Downloading the full content of an article.
•Posting Articles: Submitting new articles to a newsgroup (requires appropriate permissions).