0
votes

I am using python 2.7.2 on a windows 7 machine.

my code:

from multiprocessing import Process

def dummy_ftp_server(local_interface, username, password, homedir, perms): 
    from pyftpdlib.authorizers import DummyAuthorizer
    from pyftpdlib.handlers import FTPHandler
    from pyftpdlib.servers import FTPServer

    authorizer = DummyAuthorizer()
    authorizer.add_user(username, password, homedir, perm=perms)

    handler = FTPHandler
    handler.authorizer = authorizer

    server = FTPServer((local_interface, 21), handler)
    server.serve_forever()      

process = Process(target=dummy_ftp_server, args=('127.0.0.1', 'user', 'pass', "C:/path/test", 'elradfmw'))
process.start()

when trying to run the ftp server using multiprocessing.process i get this error

Traceback (most recent call last): File "C:\path\test_ftp.py", line 18, in dummy_ftp_server
server = FTPServer((local_interface, 21), handler)
File "C:\Python27\lib\site-packages\pyftpdlib\servers.py", line 145, in init self._af = self.bind_af_unspecified(address_or_socket)
File "C:\Python27\lib\site-packages\pyftpdlib\ioloop.py", line 733, in bind_af_unspecified raise socket.error(err)
error: [Errno 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted

if i run it without using multiprocessing.process by using

dummy_ftp_server('127.0.0.1', 'user', 'pass', "C:/path/test", 'elradfmw')

it works fine.

on a linux machine i dont have this problem.

1

1 Answers

0
votes

You are trying to run multiple ftp servers on the same ip address with the same port. That is what the error is telling you.

It could be you already have something running on 127.0.0.1:21

check in a console with netstat -an