Click here to Skip to main content
15,926,857 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Problem in my first program... Pin
xelios2-Jun-08 23:58
xelios2-Jun-08 23:58 
GeneralRe: Problem in my first program... Pin
Maxim Zarus3-Jun-08 0:16
Maxim Zarus3-Jun-08 0:16 
GeneralRe: Problem in my first program... Pin
xelios3-Jun-08 0:28
xelios3-Jun-08 0:28 
GeneralRe: Problem in my first program... Pin
Maxim Zarus3-Jun-08 1:00
Maxim Zarus3-Jun-08 1:00 
GeneralRe: Problem in my first program... [modified] Pin
xelios3-Jun-08 2:41
xelios3-Jun-08 2:41 
AnswerRe: Problem in my first program... Pin
Akt_4_U3-Jun-08 0:16
Akt_4_U3-Jun-08 0:16 
QuestionDebug - Release modes Pin
CodingLover2-Jun-08 22:26
CodingLover2-Jun-08 22:26 
AnswerRe: Debug - Release modes Pin
_AnsHUMAN_ 2-Jun-08 22:32
_AnsHUMAN_ 2-Jun-08 22:32 
AnswerRe: Debug - Release modes Pin
toxcct2-Jun-08 22:32
toxcct2-Jun-08 22:32 
NewsRe: Debug - Release modes Pin
CodingLover2-Jun-08 22:50
CodingLover2-Jun-08 22:50 
GeneralRe: Debug - Release modes Pin
CodingLover2-Jun-08 23:25
CodingLover2-Jun-08 23:25 
GeneralRe: Debug - Release modes Pin
Nibu babu thomas2-Jun-08 23:32
Nibu babu thomas2-Jun-08 23:32 
GeneralRe: Debug - Release modes Pin
CodingLover2-Jun-08 23:51
CodingLover2-Jun-08 23:51 
GeneralRe: Debug - Release modes Pin
_AnsHUMAN_ 2-Jun-08 23:59
_AnsHUMAN_ 2-Jun-08 23:59 
GeneralRe: Debug - Release modes Pin
CodingLover3-Jun-08 0:15
CodingLover3-Jun-08 0:15 
GeneralRe: Debug - Release modes Pin
David Crow3-Jun-08 3:34
David Crow3-Jun-08 3:34 
QuestionRe: Debug - Release modes Pin
CodingLover3-Jun-08 16:17
CodingLover3-Jun-08 16:17 
AnswerRe: Debug - Release modes Pin
David Crow3-Jun-08 17:04
David Crow3-Jun-08 17:04 
QuestionCreateProcess Pin
Ajay L D2-Jun-08 20:41
Ajay L D2-Jun-08 20:41 
AnswerRe: CreateProcess Pin
Akt_4_U2-Jun-08 20:59
Akt_4_U2-Jun-08 20:59 
AnswerRe: CreateProcess Pin
Hamid_RT3-Jun-08 1:34
Hamid_RT3-Jun-08 1:34 
QuestionUnable to disable http connection timer Pin
Hannes Smit2-Jun-08 20:25
Hannes Smit2-Jun-08 20:25 
I'm trying to post data from c++ code to my webservice, all works fine untill i throw in a slow network and dial-up connection. I then get a "The operation timed out" error, it always happens at exactly 30seconds, the fault is not at the webservive, his 5minute timeout is working. If someone could please just take a quick look at the code and tell me where i might have missed something.

This is my attempt to disable the timer, the value i put in appear to have no effect:
// http session
CInternetSession mySession(NULL, 1, PRE_CONFIG_INTERNET_ACCESS, NULL,
                        NULL, 0);
// http connection
CHttpConnection *pHttpConnection;
// http file pointer
CHttpFile       *pHttpFile;
// server url and object.
CString         szServerUrl, szObject;
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded");

//disable timer
mySession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,0xFFFFFFFF,0);


Here is the complete code for anyone who might be interrested, it's taken from another project here on CodeProject, but I can't seem to locate it again:
DWORD Post(CString url, CString szFormData, CString & resultString)
{
	// http session
	CInternetSession mySession(NULL, 1, PRE_CONFIG_INTERNET_ACCESS, NULL, 
							NULL, 0);
	// http connection
	CHttpConnection *pHttpConnection;
	// http file pointer
	CHttpFile		*pHttpFile;
	// server url and object.
	CString			szServerUrl, szObject;
	CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded");

	//disable timer
	mySession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,0xFFFFFFFF,0);

	// extract server and objects
	szServerUrl = url;
	ExtractObject(szServerUrl,szObject);

	try 
	{
		pHttpConnection = mySession.GetHttpConnection(szServerUrl);	

		if( NULL == pHttpConnection)
		{
			// no exception raised but there is an error. 
			return WEB_ACCESS_UNEXPECTED_ERROR;
		}
	}
	catch (CInternetException *pException)
	{
		char buffer[1023];
		pException->GetErrorMessage(buffer, 1023);
		resultString = buffer;
		return pException->m_dwError;		
	}

	// open request
	try {
		pHttpFile = pHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, szObject);

		if(NULL == pHttpFile)
		{
			return WEB_ACCESS_UNEXPECTED_ERROR;
		}
	}
	catch(CInternetException *pException)
	{
		char buffer[1023];
		pException->GetErrorMessage(buffer, 1023);
		resultString = buffer;
		return pException->m_dwError;
    }

	// send the request
	try {

		BOOL ret = pHttpFile->SendRequest(strHeaders, (LPVOID)(LPCSTR)szFormData, szFormData.GetLength());

		if( FALSE == ret )
		{
			return WEB_ACCESS_UNEXPECTED_ERROR;
		}
	}
	catch(CInternetException *pException)
	{
		char buffer[1023];
		pException->GetErrorMessage(buffer, 1023);
		resultString = buffer;
		return pException->m_dwError;
	}

	// query status code
	DWORD retCode;
	BOOL ret = pHttpFile->QueryInfoStatusCode(retCode);
	if( FALSE == ret )
	{
		return WEB_ACCESS_QUERY_INFO_ERROR;
	}
	else if( HTTP_STATUS_OK != retCode )
	{
		return retCode;
	}

	char buf[2];
	int bytesRead;
	resultString = "";
	
	while( (bytesRead = pHttpFile->Read(buf, 1)) > 0 )
	{
		resultString += buf[0];
	}
	return WEB_ACCESS_DONE;
}

AnswerRe: Unable to disable http connection timer Pin
Hannes Smit2-Jun-08 21:34
Hannes Smit2-Jun-08 21:34 
QuestionTo convert char array to LPCSTR and std::string to LPCTSTR Pin
Member 46202162-Jun-08 20:07
Member 46202162-Jun-08 20:07 
AnswerRe: To convert char array to LPCSTR and std::string to LPCTSTR Pin
KarstenK2-Jun-08 20:24
mveKarstenK2-Jun-08 20:24 

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.