Click here to Skip to main content
16,006,594 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Reading from a Text File & Database Pin
ugur_basak26-Apr-05 2:48
ugur_basak26-Apr-05 2:48 
GeneralRe: Reading from a Text File & Database Pin
ugur_basak26-Apr-05 3:14
ugur_basak26-Apr-05 3:14 
GeneralAcitveX container hanging problem Pin
kostik125-Apr-05 5:16
kostik125-Apr-05 5:16 
GeneralProblem on XP Pin
LasVegasGuy25-Apr-05 4:47
LasVegasGuy25-Apr-05 4:47 
GeneralRe: Problem on XP Pin
kostik125-Apr-05 5:23
kostik125-Apr-05 5:23 
GeneralRe: Problem on XP Pin
David Crow25-Apr-05 7:26
David Crow25-Apr-05 7:26 
GeneralHttpSendRequestExA get no connection after the third try Pin
ThinkingPrometheus25-Apr-05 4:18
ThinkingPrometheus25-Apr-05 4:18 
GeneralRe: HttpSendRequestExA get no connection after the third try Pin
ThinkingPrometheus25-Apr-05 5:00
ThinkingPrometheus25-Apr-05 5:00 
i tried the example from the msdn and i get an error 997 Overlapped I/O operation is in progress

the code:
BOOL UploadToURL::Test(TCHAR *upFile){

INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;
HINTERNET hConnect=NULL,hInternet=NULL;

hInternet=InternetOpen("User Agent",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,INTERNET_FLAG_ASYNC);
hConnect=InternetConnect(hInternet,"127.0.0.1",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,NULL);

BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS );

HINTERNET hRequest = HttpOpenRequest (hConnect, "PUT",
"/upload.php", NULL, NULL, NULL, 0, 0);
if (!hRequest)
{
printf("Failed to open request handle: %lu\n", GetLastError ());
return FALSE;
}

HANDLE hFile = CreateFile (upFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
printf("\nFailed to open local file %s.", upFile);
return FALSE;
}

BufferIn.dwBufferTotal = GetFileSize (hFile, NULL);
printf ("File size is %d\n", BufferIn.dwBufferTotal );

if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, HSR_INITIATE, 0))
{
DWORD d=GetLastError();
printf( "Error on HttpSendRequestEx %lu\n",d);

return FALSE;
}

DWORD sum = 0;
do
{
if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
&dwBytesRead, NULL)))
{
printf ("\nReadFile failed on buffer %lu.",GetLastError());
break;
}
if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
&dwBytesWritten)))
{
printf ("\nInternetWriteFile failed %lu", GetLastError());
break;
}
sum += dwBytesWritten;
}
while (dwBytesRead == sizeof(pBuffer)) ;

CloseHandle (hFile);
printf ("Actual written bytes: %d\n", sum);

if(!HttpEndRequest(hRequest, NULL, 0, 0))
{
printf( "Error on HttpEndRequest %lu \n", GetLastError());
return FALSE;
}
return TRUE;
}

but this time i get the error in the first try!
GeneralRe: HttpSendRequestExA get no connection after the third try Pin
Mike Dimmick25-Apr-05 5:17
Mike Dimmick25-Apr-05 5:17 
GeneralRe: HttpSendRequestExA get no connection after the third try Pin
ThinkingPrometheus25-Apr-05 6:11
ThinkingPrometheus25-Apr-05 6:11 
GeneralPlease help me! Pin
dSolariuM25-Apr-05 4:05
dSolariuM25-Apr-05 4:05 
GeneralRe: Please help me! Pin
ThinkingPrometheus25-Apr-05 5:13
ThinkingPrometheus25-Apr-05 5:13 
GeneralMac address! Pin
dSolariuM25-Apr-05 4:03
dSolariuM25-Apr-05 4:03 
Generaldeny the use of port 80 Pin
Holocron25-Apr-05 3:53
Holocron25-Apr-05 3:53 
Generalset color of string Pin
qtuan25-Apr-05 3:45
qtuan25-Apr-05 3:45 
GeneralFull Screen mode Pin
Aqueel25-Apr-05 2:13
Aqueel25-Apr-05 2:13 
GeneralRe: Full Screen mode Pin
Alexander M.,25-Apr-05 3:14
Alexander M.,25-Apr-05 3:14 
Questionhow do i sense ctrl+C in a dialog based application? Pin
Member 325197425-Apr-05 2:10
Member 325197425-Apr-05 2:10 
AnswerRe: how do i sense ctrl+C in a dialog based application? Pin
heman15425-Apr-05 3:57
heman15425-Apr-05 3:57 
GeneralRe: how do i sense ctrl+C in a dialog based application? Pin
ThatsAlok25-Apr-05 18:27
ThatsAlok25-Apr-05 18:27 
AnswerRe: how do i sense ctrl+C in a dialog based application? Pin
S Douglas25-Apr-05 4:43
professionalS Douglas25-Apr-05 4:43 
GeneralQuestion on adjusting app window size. Pin
Anonymous25-Apr-05 1:17
Anonymous25-Apr-05 1:17 
GeneralRe: Question on adjusting app window size. Pin
ThatsAlok25-Apr-05 1:30
ThatsAlok25-Apr-05 1:30 
GeneralRe: Question on adjusting app window size. Pin
Anonymous25-Apr-05 2:18
Anonymous25-Apr-05 2:18 
GeneralRe: Question on adjusting app window size. Pin
ThatsAlok25-Apr-05 18:48
ThatsAlok25-Apr-05 18:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.