×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

help:有用C 写过FTP 程序的DX请进

本文发表在 rolia.net 枫下论坛下面FTP GET 的一段 程序,但它只支持NON PASSIVE MODE
// Send the type command to put us into binary mode
StrPrintF(FTPCommand, "TYPE I\r\n");
NetUWriteN(FTPCtlSock, (BytePtr)FTPCommand, StrLen(FTPCommand));
if (FTPGetReply(FTPCtlSock, &reply)) goto Exit;
f (reply >= 400) goto Exit;

// Create a data port to get the results
acceptSock = FTPDataAcceptSocket();
if (acceptSock < 0) return;

// Send the RETR command
StrPrintF(FTPCommand, "RETR %s\r\n", argv[1]);
NetUWriteN(FTPCtlSock, (BytePtr)FTPCommand, StrLen(FTPCommand));

// Get Reply from the RETR command
if (FTPGetReply(FTPCtlSock, &reply)) goto Exit;
if (reply >= 400) goto Exit;

addrLen = sizeof(address);
if ((dataSock = accept (acceptSock, &address, &addrLen)) < 0) goto Exit;
errno = FTPDatabaseRead(0, argv[1], dataSock);


// Get Transer complete message
FTPGetReply(FTPCtlSock, &reply);

Exit:
if (errno) printf("\nError: %s", appErrString(errno));
if (acceptSock >= 0) close(acceptSock);
if (dataSock >= 0) close(dataSock);

如果以PASSIVE MODE 工作,上边的程序该怎么修改.更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report