C++调用HTTP(HttpSendRequest)如何设置延时
1、解决办法:
DWORD dwTimeout = 120000; // 2分钟 连接超时 bRet = InternetSetOption(hRequest, INTERNET_OPTION_CONNECT_TIMEOUT, &dwTimeout, sizeof(dwTimeout)); if (!bRet) { printf("InternetSetOption CONNECT_TIMEOUT Error: %d\n", GetLastError()); goto Ret0; } DWORD sendTimeout = 120000; // 2分钟 发送超时 bRet = InternetSetOption(hRequest, INTERNET_OPTION_SEND_TIMEOUT, &sendTimeout, sizeof(sendTimeout)); if (!bRet) { printf("InternetSetOption SEND_TIMEOUT Error: %d\n", GetLastError()); goto Ret0; } DWORD receiveTimeout = 120000; // 2分钟 接收超时 bRet = InternetSetOption(hRequest, INTERNET_OPTION_RECEIVE_TIMEOUT, &receiveTimeout, sizeof(receiveTimeout)); if (!bRet) { printf("InternetSetOption RECEIVE_TIMEOUT Error: %d\n", GetLastError()); goto Ret0; }