Can't bind with port 21 on Python
Question: I'm trying to build a simple ftp server with python, but I get an error: "An
attempt was made to access a socket in a way forbidden by its access
permissions" As I understand, it's because of the port number, but what should
I do?

Here is the code:

    
    
    import socket
    
    HOST = ''              
    PORT = 21      
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind((HOST, PORT))
    s.listen(1)
    conn, addr = s.accept()
    conn.send("220")
    data = conn.recv(1024)
    print data
    conn.send("331 Password required for", data[5:])
    conn.close()
    

Please help..


Answer: This can be a problem from the firewall or the antivirus. Try to disable them
for a quick test. If it works, start them again, and setup some exceptions for
your program.

You may also have another program currently using the port (Apache, IIS, or
else). Only one program can access one port.

