通常会设置一个超时时间1S,就是说若是php那边在1S内没有返回给urlserver的话就忽略掉该请求,及不阻塞等待返回了,直接处理下面的操做。php
如今php那边有时候会卡,这样一卡就没法再1S内返回消息给服务器服务器
因为urlserver只是忽略了该链接上的请求消息,并非断开了,因此php那边没法判断消息是不是正常发成功了仍是如何curl
因此玩家积分消耗了道具没拿到的兑换问题没法经过php捕获服务器没有收到来作。url
int connectURL(char * strUrl, char ** strResult) { *strResult = 0; if (strUrl == 0) { return 0; } CURL * pCurl; CURLcode res; int nReturn = 0; pCurl = curl_easy_init(); // init pCurl if (pCurl == NULL) { return nReturn; } res = curl_easy_setopt(pCurl, CURLOPT_ERRORBUFFER, errorBuffer); // set error buffer if (res != CURLE_OK) { goto error_return; } res = curl_easy_setopt(pCurl, CURLOPT_TIMEOUT, 1); // set time out s if (res != CURLE_OK) { goto error_return; } res = curl_easy_setopt(pCurl, CURLOPT_URL, strUrl); // set url if (res != CURLE_OK) { goto error_return; } res = curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION, writer); // set write func if (res != CURLE_OK) { goto error_return; } p_buffer.current_length = 0; if (p_buffer.cstring) p_buffer.cstring[0] = 0; res = curl_easy_setopt(pCurl, CURLOPT_WRITEDATA, &p_buffer); // set result buffer if (res != CURLE_OK) { goto error_return; } res = curl_easy_perform(pCurl); // run if (res != CURLE_OK) { goto error_return; } else { nReturn = 1; *strResult = p_buffer.cstring; } error_return: if (nReturn == 0) { printf("[WARNING][%s][%d][%s]\n", __FUNCTION__, res, errorBuffer); } curl_easy_cleanup(pCurl); return nReturn; }