我想用python在两台计算机之间传输文件.我在客户端使用ftplib模块,在服务器端使用pyftpdlib.但是,我得到错误"socket.error:[Errno 10061]没有连接,因为目标机器主动拒绝它".我的代码如下:
客户端代码:
import ftplib
ftp = ftplib.FTP("sever_ip")
ftp.login("username", "password")
ftp.retrlines("LIST")
Run Code Online (Sandbox Code Playgroud)
服务器端代码:
from pyftpdlib import servers, handlers
address = ('', 21)
server = servers.FTPServer(address, handlers.FTPHandler)
server.serve_forever()
Run Code Online (Sandbox Code Playgroud)
我运行服务器端代码并得到:
[I 15-05-28 11:14:41] >>> starting FTP server on :::21, pid=8296 <<<
[I 15-05-28 11:14:41] poller: <class 'pyftpdlib.ioloop.Select'>
[I 15-05-28 11:14:41] masquerade (NAT) address: None
[I 15-05-28 11:14:41] passive ports: None
Run Code Online (Sandbox Code Playgroud)
我运行客户端代码并得到:
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it
Run Code Online (Sandbox Code Playgroud)
我需要在目标计算机(服务器)上更改或检查哪些设置才能使其接受连接?(我的服务器是Windows Sever 2012R2,我的客户端是Windows 8)
更新:我打开了服务器的防火墙,然后重新运行了客户端请求.现在我得到了一个不同的错误:
socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a per
iod of time, or established connection failed because connected host has failed to respond
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2154 次 |
| 最近记录: |