FTP Library ReadDirectory() Error

Hello~

I have a problem with SmartFTP Library sample source win32.
The sample alaways return error(= ftpErrorWrongReply) in ReadDirectory().

So I downloaded SmartFTP Client. The client run very well.

I don't know why error. help me..
Here is the sample source code and log data.

Thank you

===============================================



sfFTPLib::IGlobalPtr pGlobal;



HRESULT hr = pGlobal.CreateInstance(__uuidof(sfFTPLib::Global));



if(SUCCEEDED(hr))



{



    // verify license key



    if(pGlobal->LoadLicenseKeyData(g_szLicenseKey) == VARIANT_TRUE)



        _tprintf(_T("License key verified.n"));



    else



        _tprintf(_T("Failed to verify license key.n"));



}







sfFTPLib::IFTPConnectionPtr ftp;



hr = ftp.CreateInstance(__uuidof(sfFTPLib::FTPConnectionMTA));



if(SUCCEEDED(hr))



{



    // AUTH TLS



    //ftp->Protocol = sfFTPLib::ftpProtocolSSLExplicit;



    ftp->Protocol = sfFTPLib::ftpProtocolNormal;



    ftp->Host = _T("[fe80::20f:20ff:fe27:95ae%4]");



    ftp->Port = 21;



    ftp->Username = _T("knkim");



    ftp->Password = _T("test123");



    ftp->Passive = VARIANT_TRUE;







    // No Proxy



    ftp->ProxyType = sfFTPLib::ftpProxyTypeNone;



    ftp->ProxyHost =_T("192.168.1.10");



    ftp->ProxyPort = 1080;



    ftp->ProxyAuthentication = VARIANT_TRUE;



    ftp->ProxyUsername = _T("user");



    ftp->ProxyPassword = _T("pass");







    // log everything 



    ftp->LogFile = _T("Win32Demo.log");







    // Connect



    sfFTPLib::enumError err = ftp->Connect();



    if(err == sfFTPLib::ftpErrorSuccess)



    {



        // change directory



        err = ftp->ChangeDirectory(_T("./"));



        if(err == sfFTPLib::ftpErrorSuccess)



        {



            printf("ChangeDirectory() OKn");



    	



            // read listing



            err = ftp->ReadDirectory();



            if(err == sfFTPLib::ftpErrorSuccess)



            {



                printf("ReadDirectory() OKn");







	sfFTPLib::IFTPDirectoryPtr pDirectory = ftp->Directory;



	if(pDirectory)



	{



                    int nCount = pDirectory->Count;



                    _tprintf(_T("Count = %dn"), nCount);  







                    // Enum



                    if(nCount > 0)



                    {



                        IEnumVARIANTPtr pEnum = pDirectory->_NewEnum;



                        VARIANT *pArrVariant = new VARIANT[nCount];



                        if(pArrVariant)



                        {



                            ULONG CeltFetched;



                            if(SUCCEEDED(pEnum->Next(nCount, pArrVariant, &CeltFetched)))



                            {



                                for(ULONG i=0; i<CeltFetched; i++)



                                {



                                    if(pArrVariant[i].vt == VT_DISPATCH)



                                    {



                                        //IDispatchPtr pDisp =;



                                        sfFTPLib::IFTPItemPtr pFTPItem = pArrVariant[i].pdispVal;



                                        if(pFTPItem)



                                        {



                                            _tprintf(_T("Type=0x%x; Name=%s; Size=%dn"), pFTPItem->Type, (LPCTSTR)pFTPItem->Name, pFTPItem->Size);



                                            if(pFTPItem->Type == sfFTPLib::ftpItemTypeLink)



                                            {



                                                _tprintf(_T("LinkPoint=%s"), (LPCTSTR)pFTPItem->LinkPoint);



                                            }



                                        }



                                    }



                                    ::VariantClear(&pArrVariant[i]);



                                }



                            }



                            delete [] pArrVariant;



                        }



                    }



                }



            }



            else



            {



                _tprintf(_T("ReadDirectory() failed. Error=%dn"), err);



                _tprintf(_T("LastReplyCode = %dn"), ftp->LastReplyCode);



                _tprintf(_T("LastReply = %sn"), (LPCTSTR)ftp->LastReply);



            }



        }



    }



    else



    {



        if(err == sfFTPLib::ftpErrorLicense)



            _tprintf(_T("Please acquire a license from https://www.smartftp.comn"));



        else



            _tprintf(_T("Connect() failed. Error=%dn"), err);



    }



}



else



{



    _tprintf(_T("Failed to create CFTPConnection instance.n"));



}



===============================================
[20050915 06:48:45] SmartFTP FTP Library v1.5.6.0
[20050915 06:48:45] Resolving host name "[fe80::20f:20ff:fe27:95ae%4]"
[20050915 06:48:45] Connecting to [fe80::20f:20ff:fe27:95ae%4] Port: 21
[20050915 06:48:45] Connected to [fe80::20f:20ff:fe27:95ae%4].
[20050915 06:48:45] 220 Gene6 FTP Server v3.6.0 (Build 23) ready...
[20050915 06:48:45] USER knkim
[20050915 06:48:45] 331 Password required for knkim.
[20050915 06:48:45] PASS test123
[20050915 06:48:45] 230 User knkim logged in.
[20050915 06:48:45] SYST
[20050915 06:48:45] 215 UNIX Type: L8
[20050915 06:48:45] FEAT
[20050915 06:48:45] 211-Extensions supported:
[20050915 06:48:45] AUTH TLS
[20050915 06:48:45] CCC
[20050915 06:48:45] CLNT
[20050915 06:48:45] CPSV
[20050915 06:48:45] EPRT
[20050915 06:48:45] EPSV
[20050915 06:48:45] MDTM
[20050915 06:48:45] MLST type*;size*;created;modify*;
[20050915 06:48:45] PASV
[20050915 06:48:45] PBSZ
[20050915 06:48:45] PROT
[20050915 06:48:45] REST STREAM
[20050915 06:48:45] SIZE
[20050915 06:48:45] SSCN
[20050915 06:48:45] TVFS
[20050915 06:48:45] UTF8
[20050915 06:48:45] XCRC "filename" SP EP
[20050915 06:48:45] XMD5 "filename" SP EP
[20050915 06:48:45] 211 End.
[20050915 06:48:45] Detected Server Software: Gene6 FTP Server 3.x
[20050915 06:48:45] OPTS UTF8 ON
[20050915 06:48:45] 501 Please CLNT first.
[20050915 06:48:45] PWD
[20050915 06:48:45] 257 "/" is current directory.
[20050915 06:48:45] CWD ./
[20050915 06:48:45] 250 CWD command successful. "/" is current directory.
[20050915 06:48:45] PWD
[20050915 06:48:45] 257 "/" is current directory.
[20050915 06:48:45] TYPE I
[20050915 06:48:45] 200 Type set to I.
[20050915 06:48:45] EPSV
[20050915 06:48:45] 501 Please try again later.

The problem seems to be with the FTP server. It returns an error in the EPSV reply:

20050915 06:48:45] EPSV
[20050915 06:48:45] 501 Please try again later.

You may want to try port mode instead of passive mode.

->Passive = false

Regards,
-Mat

Thank you for your help..

I did it fix but still error..

Here is the log data..
===============================================
[20050916 08:09:18] SmartFTP FTP Library v1.5.6.0
[20050916 08:09:18] Resolving host name "[fe80::20f:20ff:fe27:95ae%4]"
[20050916 08:09:18] Connecting to [fe80::20f:20ff:fe27:95ae%4] Port: 21
[20050916 08:09:18] Connected to [fe80::20f:20ff:fe27:95ae%4].
[20050916 08:09:18] 220 Gene6 FTP Server v3.6.0 (Build 23) ready...
[20050916 08:09:18] USER knkim
[20050916 08:09:18] 331 Password required for knkim.
[20050916 08:09:18] PASS test123
[20050916 08:09:18] 230 User knkim logged in.
[20050916 08:09:18] SYST
[20050916 08:09:18] 215 UNIX Type: L8
[20050916 08:09:18] FEAT
[20050916 08:09:18] 211-Extensions supported:
[20050916 08:09:18] AUTH TLS
[20050916 08:09:18] CCC
[20050916 08:09:18] CLNT
[20050916 08:09:18] CPSV
[20050916 08:09:18] EPRT
[20050916 08:09:18] EPSV
[20050916 08:09:18] MDTM
[20050916 08:09:18] MLST type*;size*;created;modify*;
[20050916 08:09:18] PASV
[20050916 08:09:18] PBSZ
[20050916 08:09:18] PROT
[20050916 08:09:18] REST STREAM
[20050916 08:09:18] SIZE
[20050916 08:09:18] SSCN
[20050916 08:09:18] TVFS
[20050916 08:09:18] UTF8
[20050916 08:09:18] XCRC "filename" SP EP
[20050916 08:09:18] XMD5 "filename" SP EP
[20050916 08:09:18] 211 End.
[20050916 08:09:18] Detected Server Software: Gene6 FTP Server 3.x
[20050916 08:09:18] OPTS UTF8 ON
[20050916 08:09:18] 501 Please CLNT first.
[20050916 08:09:18] PWD
[20050916 08:09:18] 257 "/" is current directory.
[20050916 08:09:18] CWD ./
[20050916 08:09:18] 250 CWD command successful. "/" is current directory.
[20050916 08:09:18] PWD
[20050916 08:09:18] 257 "/" is current directory.
[20050916 08:09:18] TYPE I
[20050916 08:09:18] 200 Type set to I.
[20050916 08:09:18] EPRT |2|fe80::20e:a6ff:fe3a:4fd5|3427|
[20050916 08:09:18] 200 Port command successful.
[20050916 08:09:18] MLSD
[20050916 08:09:18] 425 Cannot open data connection.
===============================================

and I have something strange..

At first SmartFTP client program try to run & connect => it works well
And then the sample program(passive=true) try to run => it works well too.
And then the server reboot because some reason.
And then the sample program(passive=true) try to run => error!!

I don't understand this situation.. the server setting is not change.
Why the sample program doesn't same result with same code?

Thank you..

Hmm.

I don't know. It seems to be a problem with the server which is unable to open a socket/port after it received the EPSV command.

Regards,
-Mat