FTP的LIST命令

visiond 2002-06-09 08:44:19
我用Winsock连上FTP服务器,然后传送:LIST命令,结果总返回:425 Can't open data connection.

我查了MSDN,其中说:When an FTP client passes a command to an FTP server and the client is in active mode, the client also passes a port on which it listens for the response from the server. If the client is sending a command that does not require a data port (such as the syst command), the client does not set up a data port. The ls command, also called the list command, requires a data port to return the data. If the server is expecting a data port from the client, and the server does not receive a data port, the server generates the 425 error.

但是并不有给出解决方案,我试着先传送PASV命令,但结果还是报425错。

为什么??
...全文
168 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuying 2002-06-10
  • 打赏
  • 举报
回复
FTP协议是利用2个端口分别传输命令和数据。
所以发出LIST命令的时候,如果客户端是active client,要另起一个socket,在某个端口监听,准备接收数据,同时把这个端口传送给服务器端。服务器端就会连接这个端口,传送数据。

如果客户端是pasv状态,发送pasv命令后,应该接收到服务器端传来的端口号,客户端去连接这个端口,接收数据。这主要是为了处于防火墙后面的客户使用。

使用pasv首先要确认服务器支持pasv。
zdhe 2002-06-10
  • 打赏
  • 举报
回复
configure your router,firewall,ftp proxy, confirm it does support port 20
visiond 2002-06-10
  • 打赏
  • 举报
回复
好的,我试试

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧