help:有用C 写过FTP 程序的DX请进
_bobo 2004-06-29 10:11:07 下面FTP GET 的一段 程序来自己 palm os NetSample,但它只支持NON PASSIVE MODE
// Send the type command to put us into binary mode
StrPrintF(FTPCommand, "TYPE I ");
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 ", argv[1]);
NetUWriteN(FTPCtlSock, (BytePtr)FTPCommand, StrLen(FTPCommand));
// Get Reply from the RETR command < r o l i a. n e t >
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(" Error: %s", appErrString(errno));
if (acceptSock >= 0) close(acceptSock);
if (dataSock >= 0) close(dataSock);
如果以PASSIVE MODE 工作,上边的程序该怎么修改?