当前位置: 技术问答>linux和unix
c实现FTP关于PASV的问题
来源: 互联网 发布时间:2016-03-05
本文导语: 主要是上传文件到FTP服务器,我原来是登陆以后用PORT命令,然后STOR,然后开始上传文件,现在需要改到PASV模式,但是我发送了PASV命令后该怎么做呢?继续发送STOR命令?结果程序就阻塞在这了,没返回。 ...
主要是上传文件到FTP服务器,我原来是登陆以后用PORT命令,然后STOR,然后开始上传文件,现在需要改到PASV模式,但是我发送了PASV命令后该怎么做呢?继续发送STOR命令?结果程序就阻塞在这了,没返回。
|
PASV 之后 服务器会告诉你一个地址和端口号, 并在那里listen,
客户端connect就可以了后, 就可以STOR了.
客户端connect就可以了后, 就可以STOR了.
|
可以用flashget下一个文件看看log就明白了:
Thu Feb 28 15:59:18 2008 Connecting ftp.freebsd.org:21
Thu Feb 28 15:59:18 2008 Connecting ftp.freebsd.org [IP=62.243.72.50:21]
Thu Feb 28 15:59:19 2008 Socket connected, Waiting for welcome message.
Thu Feb 28 15:59:19 2008 220 ftp.FreeBSD.org NcFTPd Server (licensed copy) ready.
Thu Feb 28 15:59:19 2008 USER anonymous
Thu Feb 28 15:59:20 2008 331 Guest login ok, send your complete e-mail address as password.
Thu Feb 28 15:59:20 2008 PASS ********
Thu Feb 28 15:59:20 2008 230-You are user #519 of 1000 simultaneous users allowed.
Thu Feb 28 15:59:21 2008 230-
Thu Feb 28 15:59:21 2008 230 Logged in anonymously.
Thu Feb 28 15:59:21 2008 Login Successful
Thu Feb 28 15:59:21 2008 REST 100
Thu Feb 28 15:59:21 2008 350 Will attempt to restart at position 100.
Thu Feb 28 15:59:21 2008 This site can resume broken downloads.
Thu Feb 28 15:59:21 2008 REST 0
Thu Feb 28 15:59:22 2008 350 Will attempt to restart at position 0.
Thu Feb 28 15:59:22 2008 TYPE A
Thu Feb 28 15:59:22 2008 200 Type okay.
Thu Feb 28 15:59:22 2008 PASV
Thu Feb 28 15:59:22 2008 227 Entering Passive Mode (62,243,72,50,210,239)
Thu Feb 28 15:59:22 2008 LIST /pub/FreeBSD/ports/i386/packages-stable/All/gettext-0.16.1_3.tbz
Thu Feb 28 15:59:23 2008 150 Data connection accepted from 192.127.94.7:50033; transfer starting.
Thu Feb 28 15:59:23 2008 -rw-r--r-- 1 ftpuser ftpusers 2137191 Jan 24 14:23 gettext-0.16.1_3.tbz
Thu Feb 28 15:59:24 2008 226 Listing completed.
Thu Feb 28 15:59:24 2008 Start Receiving Data!
Thu Feb 28 15:59:24 2008 TYPE I
Thu Feb 28 15:59:24 2008 200 Type okay.
Thu Feb 28 15:59:24 2008 PASV
Thu Feb 28 15:59:25 2008 227 Entering Passive Mode (62,243,72,50,223,24)
Thu Feb 28 15:59:25 2008 RETR /pub/FreeBSD/ports/i386/packages-stable/All/gettext-0.16.1_3.tbz
Thu Feb 28 15:59:26 2008 150 Data connection accepted from 192.127.94.7:50377; transfer starting for gettext-0.16.1_3.tbz (2137191 bytes).
Thu Feb 28 15:59:18 2008 Connecting ftp.freebsd.org:21
Thu Feb 28 15:59:18 2008 Connecting ftp.freebsd.org [IP=62.243.72.50:21]
Thu Feb 28 15:59:19 2008 Socket connected, Waiting for welcome message.
Thu Feb 28 15:59:19 2008 220 ftp.FreeBSD.org NcFTPd Server (licensed copy) ready.
Thu Feb 28 15:59:19 2008 USER anonymous
Thu Feb 28 15:59:20 2008 331 Guest login ok, send your complete e-mail address as password.
Thu Feb 28 15:59:20 2008 PASS ********
Thu Feb 28 15:59:20 2008 230-You are user #519 of 1000 simultaneous users allowed.
Thu Feb 28 15:59:21 2008 230-
Thu Feb 28 15:59:21 2008 230 Logged in anonymously.
Thu Feb 28 15:59:21 2008 Login Successful
Thu Feb 28 15:59:21 2008 REST 100
Thu Feb 28 15:59:21 2008 350 Will attempt to restart at position 100.
Thu Feb 28 15:59:21 2008 This site can resume broken downloads.
Thu Feb 28 15:59:21 2008 REST 0
Thu Feb 28 15:59:22 2008 350 Will attempt to restart at position 0.
Thu Feb 28 15:59:22 2008 TYPE A
Thu Feb 28 15:59:22 2008 200 Type okay.
Thu Feb 28 15:59:22 2008 PASV
Thu Feb 28 15:59:22 2008 227 Entering Passive Mode (62,243,72,50,210,239)
Thu Feb 28 15:59:22 2008 LIST /pub/FreeBSD/ports/i386/packages-stable/All/gettext-0.16.1_3.tbz
Thu Feb 28 15:59:23 2008 150 Data connection accepted from 192.127.94.7:50033; transfer starting.
Thu Feb 28 15:59:23 2008 -rw-r--r-- 1 ftpuser ftpusers 2137191 Jan 24 14:23 gettext-0.16.1_3.tbz
Thu Feb 28 15:59:24 2008 226 Listing completed.
Thu Feb 28 15:59:24 2008 Start Receiving Data!
Thu Feb 28 15:59:24 2008 TYPE I
Thu Feb 28 15:59:24 2008 200 Type okay.
Thu Feb 28 15:59:24 2008 PASV
Thu Feb 28 15:59:25 2008 227 Entering Passive Mode (62,243,72,50,223,24)
Thu Feb 28 15:59:25 2008 RETR /pub/FreeBSD/ports/i386/packages-stable/All/gettext-0.16.1_3.tbz
Thu Feb 28 15:59:26 2008 150 Data connection accepted from 192.127.94.7:50377; transfer starting for gettext-0.16.1_3.tbz (2137191 bytes).