本文介绍了GetHttpConnection API抛出“操作超时”例外。?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在c ++程序中使用GetHttpsConnection API时,我得到一个异常(CInternetException)操作超时。我不知道它的原因。任何人都可以帮助我吗?
代码部分:
CInternetSession oInternetSession(_T( 看门狗));
UINT nBytesRead;
CHttpConnection * pConnection = NULL;
CHttpFile * pHttpFile = NULL;
CString strUserName = _T( );
CString strPassword = _T( );
DWORD dwStatusCode;
char * chBuffer = new char [ 1024 ];
CString strLog;
try
{
pConnection = oInternetSession.GetHttpConnection(m_strHttpServer,
(INTERNET_PORT)m_nHttpPort,strUserName ,strPassword);
// 打开请求并获取HttpFile
pHttpFile = pConnection-> OpenRequest( 1 ,m_strHttpObjectName,NULL, 1 ,NULL,NULL,INTERNET_FLAG_RELOAD);
// 发送请求
pHttpFile-> SendRequest();
}
catch (CInternetException * pe)
{
TCHAR ExcText [ 1024 跨度>];
pe-> GetErrorMessage(ExcText, 1023 );
TRACE(_T( WinInet异常%s \ n),ExcText);
strLog.Format(_T( 访问网址:%s:%d /%s失败。原因: %s),m_strHttpServer,m_nHttpPort,m_strHttpObjectName,ExcText);
m_pLogger-> Log(LOGPRIO_HIGH,strLog);
pe->删除();
}
谢谢。
解决方案
When i am using GetHttpsConnection API in a c++ program, i got an exception(CInternetException) "The operation timed out". I don't know the reason for it. Can anyone help me?
code section:
CInternetSession oInternetSession(_T("Watchdog")); UINT nBytesRead ; CHttpConnection* pConnection = NULL; CHttpFile* pHttpFile = NULL; CString strUserName = _T(""); CString strPassword = _T(""); DWORD dwStatusCode; char* chBuffer = new char[1024]; CString strLog; try { pConnection = oInternetSession.GetHttpConnection(m_strHttpServer, (INTERNET_PORT) m_nHttpPort, strUserName, strPassword); //Open Request and get the HttpFile pHttpFile = pConnection->OpenRequest(1, m_strHttpObjectName ,NULL, 1, NULL, NULL,INTERNET_FLAG_RELOAD); //Send Request pHttpFile->SendRequest(); } catch(CInternetException* pe) { TCHAR ExcText[1024]; pe->GetErrorMessage(ExcText, 1023); TRACE(_T("WinInet exception %s\n"), ExcText); strLog.Format(_T("Accessing Url: %s:%d/%s failed. Reason: %s"), m_strHttpServer,m_nHttpPort, m_strHttpObjectName, ExcText); m_pLogger->Log(LOGPRIO_HIGH, strLog); pe->Delete(); }
Thanks.
解决方案
这篇关于GetHttpConnection API抛出“操作超时”例外。?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!