0% found this document useful (0 votes)
1 views5 pages

Module 6 - Chapter 4 - Network Programming - File Transfer

The document outlines a supplemental materials and enrichment activity form for a course on Integrative Programming and Technologies, focusing on File Transfer Protocol (FTP) and TCP socket programming in Python. It details the learning outcomes, server and client implementations for file transfer, and provides a practical exercise for students to create a user interface for file exploration and transfer. Additionally, it includes references for further reading on the topic.

Uploaded by

kayel.mess
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views5 pages

Module 6 - Chapter 4 - Network Programming - File Transfer

The document outlines a supplemental materials and enrichment activity form for a course on Integrative Programming and Technologies, focusing on File Transfer Protocol (FTP) and TCP socket programming in Python. It details the learning outcomes, server and client implementations for file transfer, and provides a practical exercise for students to create a user interface for file exploration and transfer. Additionally, it includes references for further reading on the topic.

Uploaded by

kayel.mess
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Supplemental Materials and Enrichment Activity Form

Program: Course:
Integrative Programming and BSIT
Technologies 1
Batch Number: Week/s Covered : Inclusive Dates:
Jan 26, 2026 to Jan 30, 2026
Faculty Name: Yr. & Sec.: Time & Day:
MLDELOSSANTOS BSIT 1-31 10:00am-4:00pm & T

MODULE 6 (Chapter 4: Network Programming – File Transfer)

Topics:
1. File Transfer Protocol
2. Sockets
Course Learning Outcomes:
At the end of this lesson students should be able to:
1. Identify the parts of Network Programming; and
2. Modify a low level data communications message and queuing services

File Transfer using TCP Socket in Python


What is FTP (File Transfer Protocol)?
FTP (File transfer protocol) is a network protocol for sending records between PCs over Transmission
Control Protocol or protocol/internet protocol (TCP/IP) associations. Inside the TCP/IP suite, FTP is
viewed as an application layer protocol. In an FTP exchange, the end client's PC is normally called the
nearby host. The subsequent PC engaged with FTP is a remote host, which is normally a server. The two
PCs should be associated by means of an organization and designed appropriately to move documents
through FTP. Servers should be gotten up positioned run FTP administrations, and the client should have
FTP programming introduced to get to these administrations.

Although many document moves can be led utilizing Hypertext Transfer Protocol (HTTP) - - one more
protocol in the TCP/IP suite - - FTP is still ordinarily used to move records in the background for different
applications, like financial administrations. It is likewise in some cases used to download new applications
through internet browsers. FTP is a standard organization convention that can empower broad document
move capacities across IP organizations. Without FTP, document and information move can be dealt with
different systems - -, for example, email or a HTTP web administration - - yet those different choices
come up short on lucidity of concentration, accuracy and control that FTP empowers.
Supplemental Materials and Enrichment Activity Form

The overall procedure for the TCP file transfer is presented in the figure below.

FTP is utilized for document moves between one framework and another, and it has a few normal use
cases, including the accompanying:

FTP can be utilized by backup services or individual clients to reinforcement information from one area to
a got reinforcement server running FTP administrations.

Like reinforcement, replication includes duplication of information starting with one framework then onto
the next yet adopts a more thorough strategy to give higher accessibility and flexibility. FTP can likewise
be utilized to work with this.

Access and data stacking. FTP is likewise ordinarily used to get to shared web facilitating and cloud
administrations as a component to stack information onto a far-off framework.

[Link]: Server-Side Implementation:


We start by bringing in the attachment library and making a straightforward socket. AF_INET alludes to
the location family ipv4. The SOCK_STREAM implies association arranged TCP convention. After this,
we tie the host address and port number to the server.

The client enters the greatest number of client associations required. Based on the info, we decide the
size of a cluster putting away clients called Associations. The server then continues to tune in for client
associations and assuming found adds them to the Associations exhibit. It does this until the Associations
exhibit arrives at its greatest breaking point. Then, at that point, for each association, processing begins,

Data is received and afterward decoded.


In the event that data is not invalid, the server makes a document with the name "Output<a unique
number>.txt" and composes it into it.
This is gone on until all information is composed into the document
The above occurs for all clients and afterward associations are shut. Thus, we can get another record at
the server's end with precisely the same data.
Supplemental Materials and Enrichment Activity Form

File Transfer: SERVER


The server performs the
following functions: import socket
IP = [Link]([Link]())
1. Create a TCP socket. PORT = 4455
2. Bind the IP address ADDR = (IP, PORT)
and PORT to the
server socket. SIZE = 1024
3. Listening for the FORMAT = "utf-8"
clients. def main():
4. Accept the connection print("[STARTING] Server is starting.")
from the client.
5. Receive the filename
""" Staring a TCP socket. """
from the client and server = [Link](socket.AF_INET,
create a text file. socket.SOCK_STREAM)
6. Send a response back """ Bind the IP and PORT to the server. """
to the client.
7. Receive the text data
[Link](ADDR)
from the client. """ Server is listening, i.e., server is now
8. Write (save) the data waiting for the client to connected. """
into the text file. [Link]()
9. Send a response
message back to the
print("[LISTENING] Server is listening.")
client. while True:
10. Close the text file. """ Server has accepted the connection from the
11. Close the connection. client. """
conn, addr = [Link]()
print(f"[NEW CONNECTION] {addr} connected.")
""" Receiving the filename from the client. """
filename = [Link](SIZE).decode(FORMAT)
print(f"[RECV] Receiving the filename.")
file = open(filename, "w")
[Link]("Filename received.".encode(FORMAT))
""" Receiving the file data from the client. """
data = [Link](SIZE).decode(FORMAT)
print(f"[RECV] Receiving the file data.")
[Link](data)
[Link]("File data received".encode(FORMAT))
""" Closing the file. """
[Link]()
""" Closing the connection from the client. """
[Link]()
print(f"[DISCONNECTED] {addr} disconnected.")
if __name__ == "__main__":
main()
Supplemental Materials and Enrichment Activity Form

[Link]: Client-side
Implementation: import socket
We initially make an socket for a client
and interface it to the server utilizing
IP = [Link]([Link]())
the tuple containing the host address PORT = 4455
and port number. Then, at that point, ADDR = (IP, PORT)
the Client enters the record name it FORMAT = "utf-8"
needs to ship off the server. After this,
SIZE = 1024
utilizing the open() capability of Python,
the information of the record is def main():
perused. Information is perused line-by- """ Staring a TCP socket. """
line and afterward encoded into double client = [Link](socket.AF_INET,
and shipped off the server utilizing
socket.SOCK_STREAM)
socket. send(). While sending
information is done, the record is shut. """ Connecting to the server. """
It continues to request a filename from [Link](ADDR)
the client until the client association is """ Opening and reading the file data. """
ended.
file = open("data/[Link]", "r")
File Transfer: CLIENT data = [Link]()
The client performs the following """ Sending the filename to the server. """
functions: [Link]("[Link]".encode(FORMAT))
msg = [Link](SIZE).decode(FORMAT)
1. Create a TCP socket for the
client. print(f"[SERVER]: {msg}")
2. Connect to the server. """ Sending the file data to the server. """
3. Read the data from the text file. [Link]([Link](FORMAT))
4. Send the filename to the
msg = [Link](SIZE).decode(FORMAT)
server.
5. Receive the response from the print(f"[SERVER]: {msg}")
server. """ Closing the file. """
6. Send the text file data to the [Link]()
server. """ Closing the connection from the server. """
7. Receive the response from the
server. [Link]()
8. Close the file. if __name__ == "__main__":
9. Close the connection. main()
Supplemental Materials and Enrichment Activity Form

References:

[Link]
c5cf3899819c
[Link]

Exercise 6: File Transfer Protocol

Client
Create a user interface of File Explorer in Python. Copy a file to your current directory.

Server
Start the server and allow the client to transfer the file.

You might also like