Newsgroups : Microsoft : microsoft.public.inetsdk.programming.wininet : 2007 Aug : 12031 Error
| Subject: | 12031 Error |
| Posted by: | "Prab" (visitprabhak..@gmail.com) |
| Date: | Tue, 21 Aug 2007 00:52:27 |
Hi Guys,
I GET 12031 error at this Function below i have Complete Code please
let me know what could be the reason.I Checked in the Debug Mode Code
Works untill i reach this line.Once debug enters this line the error
is generated...................
if(!HttpEndRequest(hRequest, NULL, 0, 0))
HINTERNET hINet, hConnection, hData;
CHAR buffer[2048] ;
CString m_strContents ;
DWORD dwRead, dwFlags, dwStatus ;
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;
hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0 );
if ( !hINet )
{
MessageBox("InternetOpen Failed");
}
hConnection = InternetConnect( hINet, "http://192.168.1.57/
uploadFile.php", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
InternetCloseHandle(hINet);
MessageBox("Failed to Connect!");
}
BufferIn.dwStructSize=sizeof(INTERNET_BUFFERS);
hRequest = HttpOpenRequest (hConnection, "PUT","/Test/Date.txt", NULL,
NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (!hRequest)
{
MessageBox("Failed to open request handle!");
}
TCHAR *upFile;
upFile="d:\Date.txt";
HANDLE hFile = CreateFile (upFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox("Failed to open local file!");
}
BufferIn.dwBufferTotal = GetFileSize (hFile, NULL);
if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, HSR_INITIATE,
0))
{
MessageBox("Error on HttpSendRequestEx!");
}
DWORD sum = 0;
do
{
if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
&dwBytesRead, NULL)))
{
MessageBox("ReadFile failed on buffer!");
break;
}
if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
&dwBytesWritten)))
{
MessageBox("File Uploading Failed!");
break;
}
sum += dwBytesWritten;
}
while (dwBytesRead == sizeof(pBuffer)) ;
CloseHandle (hFile);
if(!HttpEndRequest(hRequest, NULL, 0, 0)) //////////// I GET
HERE 12031 ERROR /////////////
{
int err = GetLastError();
MessageBox("12030 Server Terminated Connection!");
}
InternetCloseHandle(hConnection);InternetCloseHandle(hINet);
//InternetCloseHandle(hData);