Discussion:
FtpCommand & 'NLST'
(too old to reply)
raykos
2004-10-06 11:57:02 UTC
Permalink
Hello group,

I'm using the 'FtpCommand' in synchronous mode and I'm able to get back a
data buffer when I send 'NLST'; but, since I'm synchronous is there any way
of knowing and reading when the '226 data channel closed' comes back, since
this response
is coming from the control channel? I can use 'InternetGetLastResponseInfo',
but when to use it, since I don't know when something is available?

FtpCommand(g_hConnection, TRUE, FTP_TRANSFER_TYPE_ASCII,
"NLST", 0, &g_hResponse);

::InternetGetLastResponseInfo(&temp_int,temp_str,&length);

InternetReadFile(g_hResponse,bDataBuffer,4096,&dwBytesRead);

while(dwBytesRead > 0)
{
bDataBuffer[dwBytesRead] = '\0';
InternetReadFile(g_hResponse,bDataBuffer,4096,&dwBytesRead);
}

::InternetGetLastResponseInfo(&temp_int,temp_str,&length);


Any help appreciated,

TIA,
Ray K.
Paul Baker [MVP, Windows - SDK]
2004-10-06 18:41:33 UTC
Permalink
I think you need to send a PASV or PORT command, then an NLST command, then
open the port to get the listing using WinSock.

Paul
Post by raykos
Hello group,
I'm using the 'FtpCommand' in synchronous mode and I'm able to get back a
data buffer when I send 'NLST'; but, since I'm synchronous is there any way
of knowing and reading when the '226 data channel closed' comes back, since
this response
is coming from the control channel? I can use
'InternetGetLastResponseInfo',
Post by raykos
but when to use it, since I don't know when something is available?
FtpCommand(g_hConnection, TRUE, FTP_TRANSFER_TYPE_ASCII,
"NLST", 0, &g_hResponse);
::InternetGetLastResponseInfo(&temp_int,temp_str,&length);
InternetReadFile(g_hResponse,bDataBuffer,4096,&dwBytesRead);
while(dwBytesRead > 0)
{
bDataBuffer[dwBytesRead] = '\0';
InternetReadFile(g_hResponse,bDataBuffer,4096,&dwBytesRead);
}
::InternetGetLastResponseInfo(&temp_int,temp_str,&length);
Any help appreciated,
TIA,
Ray K.
Loading...