Home > Software engineering >  Could be CInternetSession mistake
Could be CInternetSession mistake

Time:10-13

 
String CDanDanSourceData: : GetPCDanDanSourceData (string strURL)
{
CInternetSession session;
CHttpFile * file=NULL;
//string strNewURL=strURL + strAddURL;
Cstrings cstrURL=CGlobalOpt: : CharToWchar (strURL c_str ());
String strValue;
Cstrings cstrValue;
Char szBuff [2048].

//INTERNET_PROXY_INFO proxyinfo;
//proxyinfo. DwAccessType=INTERNET_OPEN_TYPE_PROXY;
//proxyinfo lpszProxy="211.104.243.73:8080";
//proxyinfo. LpszProxyBypass=NULL;
//session. SetOption (INTERNET_OPTION_PROXY, (LPVOID) & amp; Proxyinfo,
//sizeof (INTERNET_PROXY_INFO));

The session. SetOption (INTERNET_OPTION_CONNECT_TIMEOUT, 500);//5 connection timeout
The session. SetOption (INTERNET_OPTION_SEND_TIMEOUT, 500);//1 seconds to send timeout
The session. SetOption (INTERNET_OPTION_RECEIVE_TIMEOUT, 500);//7 seconds to receive timeout
The session. SetOption (INTERNET_OPTION_DATA_SEND_TIMEOUT, 500);//1 seconds to send timeout
The session. SetOption (INTERNET_OPTION_DATA_RECEIVE_TIMEOUT, 500);//7 seconds to receive timeout
//session. SetOption (INTERNET_OPTION_CONNECT_RETRIES, 1);//1 retries

Try {
The file=(CHttpFile *) session. OpenURL (cstrURL, 1,
INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE);
{} the catch (CInternetException * m_pException)
The file=NULL;
M_pException - & gt; M_dwError;
M_pException - & gt; The Delete ();
The session. The Close ();
LOGERROR (" CInternetException ");
//MessageBox (" CInternetException ");
return "";
}
//cstrings strLine;
If (the file!=NULL)
{
While (file - & gt; ReadString (LPTSTR szBuff, sizeof (szBuff)/2-2)!=NULL)
{
StrValue +=szBuff;
}
}
The else
{
LOGERROR (" fail ");
return "";
}
File - & gt; Close ();
The session. The Close ();
Return strValue;
}

==
My program is running for a period of time will pop up "operation timed out" mistakes, I doubt that is the function of the session. The OpenURL function quote, if is the function of, is there a way to not let it play out?

CodePudding user response:

CInternetSession: : OpenURL ()

This method can throw exceptions of type CInternetException *.

CodePudding user response:

reference 1st floor VisualEleven response:
CInternetSession: : OpenURL ()

This method can throw exceptions of type CInternetException *.

I have catch this exception, why still prompt box? How to solve

CodePudding user response:

Capture the abnormal after
 
//e - & gt; ReportError ();//don't try this
E - & gt; The Delete ();

CodePudding user response:

The
reference 3 floor dingxz105090 response:

after capture the abnormal
 
//e - & gt; ReportError ();//don't try this
E - & gt; The Delete ();

Let me try first

CodePudding user response:

The
reference 3 floor dingxz105090 response:

after capture the abnormal
 
//e - & gt; ReportError ();//don't try this
E - & gt; The Delete ();

I don't have this

CodePudding user response:

The
reference 3 floor dingxz105090 response:

after capture the abnormal
 
//e - & gt; ReportError ();//don't try this
E - & gt; The Delete ();

You are to say to catch exceptions, calls e - & gt; Delete () this?

CodePudding user response:

Comment out LOGERROR (" CInternetException "); Take a look at

CodePudding user response:

The system prompt operation, overtime? Rather than the program prompts you, don't know if the original poster is the problem

CInternetSession OpenURL, if the network is not, will be stuck here, this interface will be stuck more than 10 seconds

Session. SetOption the building through the set timeout, you think really works? I tried to use, or the card more than 10 seconds

CodePudding user response:

refer to the eighth floor cvbtvbwu response:
operation timeout, prompted? Rather than the program prompts you, don't know if the original poster is the problem

CInternetSession OpenURL, if the network is not, will be stuck here, this interface will be stuck more than 10 seconds

Session. SetOption the building through the set timeout, you think really works? I tried to use, a more than 10 seconds or card

Can't be prompted

CodePudding user response:

refer to 7th floor CharlesSimonyi response:
comment out LOGERROR (" CInternetException "); See

With this it doesn't matter, this error LOG is printed on my own

CodePudding user response:

The
reference 3 floor dingxz105090 response:

after capture the abnormal
 
//e - & gt; ReportError ();//don't try this
E - & gt; The Delete ();

I call is to delete

CodePudding user response:

Is this a few lines of timeout results


The session. SetOption (INTERNET_OPTION_CONNECT_TIMEOUT, 500);//5 connection timeout
The session. SetOption (INTERNET_OPTION_SEND_TIMEOUT, 500);//1 seconds to send timeout
The session. SetOption (INTERNET_OPTION_RECEIVE_TIMEOUT, 500);//7 seconds to receive timeout
The session. SetOption (INTERNET_OPTION_DATA_SEND_TIMEOUT, 500);//1 seconds to send timeout
The session. SetOption (INTERNET_OPTION_DATA_RECEIVE_TIMEOUT, 500);//receive overtime 7 seconds

CodePudding user response:

The
refer to 12 floor dingxz105090 reply:
that is this a few lines of timeout results


nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related