1,502
社区成员
发帖
与我相关
我的任务
分享
Dim XMLObject As Object
Dim SendStr As String
Dim ReturnText As String
Dim ReturnBody() As Byte
Dim lResolve As Long
Dim lConnect As Long
Dim lSend As Long
Dim lReceive As Long
lResolve = 2 * 1000 '2秒 域名分析超时
lConnect = 2 * 1000 '2秒 连接站点超时
lSend = 3 * 1000 '3秒 发送数据时间超时
lReceive = 2 * 1000 '2秒 等待反馈时间超时
Set XMLObject = CreateObject("MSXML2.ServerXMLHTTP")
XMLObject.setTimeouts lResolve, lConnect, lSend, lReceive
SendStr = "http://" & lpServerIP & "/ServerTime.asp"
XMLObject.open "GET", SendStr, False
XMLObject.setRequestHeader "CONTENT-TYPE", "application/x-www-form-urlencoded"
XMLObject.send
If XMLObject.Status <> 200 Then
NetworkState = False
Else
NetworkState = True
ReturnBody = XMLObject.responseBody
ReturnText = StrConv(ReturnBody, vbUnicode)
'...
End If
MSXML2::IServerXMLHTTPRequestPtr XMLObject;
MCString SendStr;
MCString ReturnText;
VARIANT ReturnBody;
//SYSTEMTIME SystemTimeValue;
long lResolve = 2 * 1000; //2秒 域名分析超时
long lConnect = 2 * 1000; //2秒 连接站点超时
long lSend = 3 * 1000; //3秒 发送数据时间超时
long lReceive = 2 * 1000; //2秒 等待反馈时间超时
XMLObject.CreateInstance("MSXML2.ServerXMLHTTP");
XMLObject->setTimeouts(lResolve,lConnect,lSend,lReceive);
SendStr = "http://";
SendStr &= lpServerIP;
SendStr &= "/ServerTime.asp";
XMLObject->open(_bstr_t("GET"),_bstr_t(*SendStr),_variant_t("false"));
XMLObject->setRequestHeader(_bstr_t("CONTENT-TYPE"),_bstr_t("application/x-www-form-urlencoded"));
XMLObject->send();
if(XMLObject->status!=200){
NetworkState = FALSE;
}else{
NetworkState = TRUE;
XMLObject->get_responseBody(&ReturnBody);
ReturnText = BodyToChars(&ReturnBody);
ReturnText.Erase();
...
}