FTP 的LIST命令

visiond 2002-06-09 08:44:47
我用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错。

为什么??
...全文
509 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
朝阳群众001 2002-06-10
  • 打赏
  • 举报
回复
xuying正解。
1 如果不用pasv模式, 先开一个socket, listen等待FTP数据连接。
发PORT命令告诉对方这个IP, 段口号.
然后list.
2 pasv模式则先发pasv, 服务器会告诉你它的IP, 端口
开一个socket, 连上这个。
LIST
这种模式可以过NAT, 就是自己没有IP, 几台机公用一个IP上网的情况

visiond 2002-06-10
  • 打赏
  • 举报
回复
好的,我试试
ckc 2002-06-09
  • 打赏
  • 举报
回复
防火墙/路由器设置不当。
或者ftp server也在防火墙或者路由器里面,这时候PASV也是不灵的。
xuying 2002-06-09
  • 打赏
  • 举报
回复
FTP协议是利用2个端口分别传输命令和数据。
所以发出LIST命令的时候,如果客户端是active client,要另起一个socket,在某个端口监听,准备接收数据,同时把这个端口传送给服务器端。服务器端就会连接这个端口,传送数据。

如果客户端是pasv状态,发送pasv命令后,应该接收到服务器端传来的端口号,客户端去连接这个端口,接收数据。这主要是为了处于防火墙后面的客户使用。
  • 打赏
  • 举报
回复
你退出你的防火墙!
然后再用命令

4,387

社区成员

发帖
与我相关
我的任务
社区描述
通信技术相关讨论
社区管理员
  • 网络通信
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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