gpt4 book ai didi

c - 在我的 FTP 服务器上列出目录时出现 "bare linefeeds received in ASCII mode"警告

转载 作者:太空宇宙 更新时间:2023-11-04 00:02:30 25 4
gpt4 key购买 nike

我正在创建一个 FTP 服务器作为一个学校项目,大多数命令都在工作,我几乎确定了 PORT(数据传输的主动模式)。

像这样使用 ftp 启动我的服务器:

ftp localhost 4242 // where 4242 is the port on which my server is listening

登录后使用命令 ls,我收到一个有效的 ls 输出,后跟此消息:

WARNING! 8 bare linefeeds received in ASCII mode File may not have transferred correctly.

请注意,在 ftp 中使用 ls 时,它会在使用 LIST 命令之前自动切换到事件模式。

此错误表示什么?

完整输出:

200 Active Mode Enabled.
150 Directory listing.
total 56
drwxrwxr-x 4 kade_c kade_c 4096 mai 12 15:24 .
drwxr-xr-x 38 kade_c kade_c 4096 mai 12 14:58 ..
drwxrwxr-x 8 kade_c kade_c 4096 mai 12 15:17 .git
-rw-rw-r-- 1 kade_c kade_c 1726 mai 11 10:35 Makefile
-rw-rw-r-- 1 kade_c kade_c 161 mai 11 11:43 README.txt
-rwxrwxr-x 1 kade_c kade_c 29368 mai 12 15:24 server
drwxrwxr-x 4 kade_c kade_c 4096 mai 2 18:40 server_src
WARNING! 8 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 LIST complete.

最后,这是创建、连接到套接字并执行 ls -la 的代码部分:

server_write(client, "150 Directory listing.\r\n");
if (connect_data(client) == -1) // Creates socket and connects to it
{
server_write(client, "520 Impossible to reach client.\r\n");
return;
}
ofd = xdup(1);
xdup2(client->data.socket, 1);
system("ls -la");
xdup2(ofd, 1);
server_write(client, "226 LIST complete.\r\n");
close_data(client, -1);

最佳答案

此问题是因为您正在以 ASCII 模式下载文件。切换到二进制模式将使警告消失。

登录到 FTP 服务器后,键入 binary,然后开始下载。

ftp> binary
200 Type set to I.

您只需在每个 FTP session 中运行一次此命令。

关于c - 在我的 FTP 服务器上列出目录时出现 "bare linefeeds received in ASCII mode"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37187986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com