FTP客户端NLST命令问题

mvwan 2019-05-27 06:39:33
发送"PWD"命令没有问题,列出文件列表不可以,是哪里得问题?

bool file_list()
{
char buf[buf_size] = { 0 };
std::string file_buf = "PWD \r\n";
send(down_socket, file_buf.c_str(), file_buf.length(), 0);
recv(down_socket, buf, sizeof(buf), 0);
std::cout << "当前目录:" << buf << std::endl;

file_buf = "NLST ";
file_buf.append("/e:/EFTP/");
file_buf.append("\r\n");
int r_s = send(down_socket, file_buf.c_str(), file_buf.length(), 0);

memset(buf, 0, sizeof(buf));
recv(down_socket, buf, sizeof(buf), 0);
std::cout << "文件列表:" << buf << std::endl;

return true;




...全文
748 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mvwan 2019-05-28
  • 打赏
  • 举报
回复
我X,接收得信息是在数据端口接收。
mvwan 2019-05-28
  • 打赏
  • 举报
回复
是服务端不支持这个命令吗?在命令行也是无法使用。
mvwan 2019-05-28
  • 打赏
  • 举报
回复
下面是serv-u得域日志,版本是6 [7] Tue 28May19 10:30:00 - Sock ID=3 TH_ACCEPT - handle=948 [7] Tue 28May19 10:30:00 - Sock ID=66 ioctlsocket(948,FIONBIO,0x02B2EA34) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 WSAAsyncSelect(948,462700,1024,FD_READ FD_WRITE FD_CLOSE) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 getsockname(948,0x02B2E83C,0x02B2E9C4) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 inet_ntoa() --> 127.0.0.1 [7] Tue 28May19 10:30:00 - Sock ID=66 getpeername(948,0x02B2EA20,0x02B2EA38) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 inet_ntoa() --> 127.0.0.1 [7] Tue 28May19 10:30:00 - Sock ID=66 setsockopt(948,SOL_SOCKET,SO_OOBINLINE,0x02B2E920,4) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 setsockopt(948,SOL_SOCKET,SO_KEEPALIVE,0x02B2E910,4) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 setsockopt(948,IPPROTO_TCP,TCP_NODELAY,0x02B2E900,4) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 setsockopt(948,SOL_SOCKET,SO_SNDBUF,0x02B2E8F4,4) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 setsockopt(948,SOL_SOCKET,SO_RCVBUF,0x02B2E8E4,4) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 getsockname(948,0x02B2D7C8,0x02B2D950) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 inet_ntoa() --> 127.0.0.1 [7] Tue 28May19 10:30:00 - Sock ID=66 getsockname(948,0x02B2D9B4,0x02B2D9C4) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 ntohs(0x1500) --> 0x15 [7] Tue 28May19 10:30:00 - Sock ID=66 getpeername(948,0x02B2D9AC,0x02B2D9C4) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 inet_ntoa() --> 127.0.0.1 [5] Tue 28May19 10:30:00 - (000023) Connected to 127.0.0.1 (Local address 127.0.0.1) [7] Tue 28May19 10:30:00 - Sock ID=66 setsockopt(948,SOL_SOCKET,SO_KEEPALIVE,0x02B2CB68,4) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 FD_WRITE Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 RB_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> -1 (WSAEWOULDBLOCK) [7] Tue 28May19 10:30:00 - Sock ID=66 WSAGetLastError() --> WSAEWOULDBLOCK [6] Tue 28May19 10:30:00 - (000023) 220 Serv-U FTP Server v6.0 for WinSock ready... [7] Tue 28May19 10:30:00 - Sock ID=66 RB_WRITE Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 send(948,0x02671A94,49,0) --> 49 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 FD_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> 16 (OK) [2] Tue 28May19 10:30:00 - (000023) USER anonymous [6] Tue 28May19 10:30:00 - (000023) 331 User name okay, please send complete E-mail address as password. [7] Tue 28May19 10:30:00 - Sock ID=66 RB_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> -1 (WSAEWOULDBLOCK) [7] Tue 28May19 10:30:00 - Sock ID=66 WSAGetLastError() --> WSAEWOULDBLOCK [7] Tue 28May19 10:30:00 - Sock ID=66 RB_WRITE Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 send(948,0x02671A94,70,0) --> 70 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 FD_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> 7 (OK) [2] Tue 28May19 10:30:00 - (000023) PASS [5] Tue 28May19 10:30:00 - (000023) ANONYMOUS logged in, password: [6] Tue 28May19 10:30:00 - (000023) 230 User logged in, proceed. [7] Tue 28May19 10:30:00 - Sock ID=66 RB_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> -1 (WSAEWOULDBLOCK) [7] Tue 28May19 10:30:00 - Sock ID=66 WSAGetLastError() --> WSAEWOULDBLOCK [7] Tue 28May19 10:30:00 - Sock ID=66 RB_WRITE Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 send(948,0x02671A94,30,0) --> 30 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 FD_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> 6 (OK) [2] Tue 28May19 10:30:00 - (000023) PASV [7] Tue 28May19 10:30:00 - Sock ID=67 socket(PF_INET,SOCK_STREAM,0) --> 908 (OK) [7] Tue 28May19 10:30:00 - Sock ID=67 inet_addr(127.0.0.1) --> 0x100007F [7] Tue 28May19 10:30:00 - Sock ID=67 htons(0x0) --> 0x0 [7] Tue 28May19 10:30:00 - Sock ID=67 bind(908,0x02B2CE8C,16) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=67 listen(908,5) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=67 DispatchThread() --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=67 getsockname(908,0x02B2CF54,0x02B2CF64) --> 0 (OK) [7] Tue 28May19 10:30:00 - Sock ID=67 ntohs(0x6CE) --> 0xCE06 [6] Tue 28May19 10:30:00 - (000023) 227 Entering Passive Mode (127,0,0,1,206,6) [7] Tue 28May19 10:30:00 - Sock ID=66 RB_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> -1 (WSAEWOULDBLOCK) [7] Tue 28May19 10:30:00 - Sock ID=66 WSAGetLastError() --> WSAEWOULDBLOCK [7] Tue 28May19 10:30:00 - Sock ID=66 RB_WRITE Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 send(948,0x02671A94,45,0) --> 45 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 FD_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> 6 (OK) [2] Tue 28May19 10:30:00 - (000023) PWD [6] Tue 28May19 10:30:00 - (000023) 257 "/d:/temp" is current directory. [7] Tue 28May19 10:30:00 - Sock ID=66 RB_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> -1 (WSAEWOULDBLOCK) [7] Tue 28May19 10:30:00 - Sock ID=66 WSAGetLastError() --> WSAEWOULDBLOCK [7] Tue 28May19 10:30:00 - Sock ID=66 RB_WRITE Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 send(948,0x02671A94,38,0) --> 38 (OK) [7] Tue 28May19 10:30:00 - Sock ID=66 FD_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> 17 (OK) [2] Tue 28May19 10:30:00 - (000023) LIST /d:/temp/1 [7] Tue 28May19 10:30:00 - Sock ID=66 RB_READ Stat=OK [7] Tue 28May19 10:30:00 - Sock ID=66 recv(948,0x026927C4,2048,0) --> -1 (WSAEWOULDBLOCK) [7] Tue 28May19 10:30:00 - Sock ID=66 WSAGetLastError() --> WSAEWOULDBLOCK

5,530

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 模式及实现
社区管理员
  • 模式及实现社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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