I have an FTP server on address ftp://192.168.1.14/
and port 21
. I want to make a program in Python to connect to it and download it's files. It is my homework and I have to use TCP
. My problem statement is
"You are required to implement a simple FTP operation using python-based TCP protocol. You will have to create an FTP server and client. Then you will have to create a TCP socket (SOC_SREAM) and establish connection between the server and the client module you created (programmed).Once the connection is established you are required to transfer a file (text file you store on server directory) to the client directory."
I was able to do it using ftplib
but now I want to do it using simple socket tcp. What I have done so far is
import socket
s = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
s.bind(('ftp://192.168.1.14/', 21))
#also tried s.bind((socket.gethostname(), 21))
but I am receiving error which is
Traceback (most recent call last):
File "server.py", line 34, in <module>
s.bind(('ftp://192.168.1.14/', 21))
socket.gaierror: [Errno 11001] getaddrinfo failed
Hopefully you can help me. Thanks
EDIT:
when using s.bind((socket.gethostname(),21))
the error message is
Traceback (most recent call last):
File "server.py", line 34, in <module>
s.bind((socket.gethostname(), 21))
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions