Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi.

i try to use the ftp commands in c++.
Its throwing the error as 997.. "Overlapped I/O operation is in progress".

Code:

C++
HINTERNET  hHandle = InternetOpen("s", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
	if( hHandle  != NULL )
	{
		printf("Success");
	}
	
	HINTERNET  hFtpSession = InternetConnect( hHandle, "172.16.11.33", INTERNET_DEFAULT_FTP_PORT, "XXXX", "12345", INTERNET_SERVICE_FTP, NULL, NULL);
	if( hFtpSession != NULL )
	{
		printf("\nSucces:");
	}
	else
	{
		printf("\nFailed %d", GetLastError());
	}

	FtpPutFile(hFtpSession, "C:\\1.txt", " mylog.txt", FTP_TRANSFER_TYPE_BINARY, 0);
	char chTemp[1024] = "";
	DWORD dw = sizeof(chTemp);
	
	if( FtpGetCurrentDirectory(hFtpSession, chTemp,&dw) == TRUE )
	{
		printf("\nSuccess");
	}
	else
	{
		printf("\nError::%d", GetLastError());
	}
Posted
Updated 16-Sep-14 0:51am
v3

You are using asynchronous mode (INTERNET_FLAG_ASYNC). In this case, all functions will return immediately without waiting for the requested action to be finished. The error 997 / ERROR_IO_PENDING indicates that such an action has not been finished yet.

With asynchronous operations, use the InternetSetStatusCallback[^] function to be notified when operations has been finished. See also the Asynchronous Example Application[^] in the MSDN.
 
Share this answer
 
Comments
H.Brydon 21-Jan-13 10:37am    
Complete and correct ... +5
@BangIndia 22-Jan-13 1:22am    
ftpcreateDirectory is giving error as 19...
but permission i provided. i can able to create from cmd line.
i used the FtpGetCurrentDirectory also. its giving the valid path
Jochen Arndt 22-Jan-13 3:09am    
This not really related to your initial question and my answer.
Error 19 is ERROR_WRITE_PROTECT and makes no sense here. What do you mean by cmd line? FtpCreateDirectory() creates a directory on the FTP server.
HINTERNET hHandle = InternetOpen("s", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0)

Specify the last parameter to InternetOpen() as 0 and in FtpCreateDirectory() use forward slash("/") instead of back slash("\") as a path separator .
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900