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 *.