Click here to Skip to main content
15,924,553 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
AnswerRe: To convert char array to LPCSTR and std::string to LPCTSTR Pin
Jijo.Raj2-Jun-08 20:29
Jijo.Raj2-Jun-08 20:29 
QuestionRegarding remote execution Pin
H4u322-Jun-08 18:38
H4u322-Jun-08 18:38 
AnswerRe: Regarding remote execution Pin
Rajesh R Subramanian2-Jun-08 20:20
professionalRajesh R Subramanian2-Jun-08 20:20 
GeneralRe: Regarding remote execution Pin
H4u322-Jun-08 21:37
H4u322-Jun-08 21:37 
GeneralRe: Regarding remote execution Pin
Rajesh R Subramanian2-Jun-08 22:05
professionalRajesh R Subramanian2-Jun-08 22:05 
GeneralRe: Regarding remote execution Pin
H4u322-Jun-08 23:42
H4u322-Jun-08 23:42 
AnswerRe: Regarding remote execution Pin
Rajesh R Subramanian3-Jun-08 1:01
professionalRajesh R Subramanian3-Jun-08 1:01 
GeneralRe: Regarding remote execution Pin
H4u323-Jun-08 2:18
H4u323-Jun-08 2:18 
GeneralRe: Regarding remote execution Pin
Rajesh R Subramanian3-Jun-08 3:30
professionalRajesh R Subramanian3-Jun-08 3:30 
Questionhow to get process start time in vc? Pin
ftbk2-Jun-08 18:09
ftbk2-Jun-08 18:09 
AnswerRe: how to get process start time in vc? Pin
_AnsHUMAN_ 2-Jun-08 18:34
_AnsHUMAN_ 2-Jun-08 18:34 
AnswerRe: how to get process start time in vc? Pin
Paresh Chitte2-Jun-08 18:40
Paresh Chitte2-Jun-08 18:40 
AnswerRe: how to get process start time in vc? Pin
Hamid_RT3-Jun-08 1:32
Hamid_RT3-Jun-08 1:32 
QuestionPlease help me to solve a problem about global mouse hook Pin
capint2-Jun-08 18:01
capint2-Jun-08 18:01 

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.