In: Computer Science
Answer as soon as possible!!!
Code must be done with Python
Develop a basic File Transfer Protocol (FTP) application that transmits files between a client and a server using Python. Your programs should implement four FTP commands: (1) change directory (cd), (2) list directory content (ls), (3) copy a file from client to a server (put) and (4) copy a file from a server to a client (get). Implement two versions of the program: one that uses stock TCP for reliable data transfer; and one that implements stop-and-wait reliability at the application layer and uses UDP for transport.
So therefore it has to have client-server TCP implementation and UPD implementation.
FTP programming python using ftplib library, are connect to FTp servers,or download and upload files.
FTP is network protocol it use for transfering files with client and server on a computer network,it has DELE,RETR or CWD communication with FTP commands.
1) Change Directory :- The use purpose for change directory cwd() method the current working directory.
for example:-
FTP with ftplib, as cover both uploading and downloading files with a remote server.
// Set has domain name or server ip address//
ftp = FTP ('server.ip')
ftp.login(user= 'username', pass = 'password')
// Will connect you to your remote server. You can then change into
a specific directory.
ftp.cwd('/abc/')
2) List Directory Content:- It has retrieve a file or directory listing in transfer mode of LIST retrieves a list of files and information about those files.
It use for retrlines
command.
for examples:-
ftps.retrlines('LIST') // Set list directory content securely.
3,4) Copy a file from client to a server:- FTP is the process of copying or moving a file for computer to anathor network or Internet connection.
It's create a server that listens on a particular port, and server will be responce for file receiving, the client will try to connect to the server and send a file of any type.
Its socket module going to use build-in with python and with socket operations, it use for internet are behind of any connection or any network.
for examples:-
// Set import socket
import socket
BUFFER_SIZE = 5016 // Set 5016 byte
// It specify the IP address or port of the server to connect name file we want to send.
host = "192.168.1.110"
port = 5001
filename = "abcData.csv"
filesize = os.path.getsize
Filename it use to current directory,and use for absolute path to that file somewhere in your computer.
The os.path.getsize get the size of file in byte.