请问如何编程与iis服务器通信.. 即通过程序模拟浏览器访问iis服务器...框架是怎样的?谢谢//[最好c/c++环境] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http协议IE 访问头部:GET /1.asp?id=323432 HTTP/1.1Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*Accept-Language: zh-cnAccept-Encoding: gzip, deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)Host: www.hch.comConnection: Keep-Alive. http://member.netease.com/~maqianli/vc/Document/D_142.htm 给你端和服务器通讯的代码CInternetSession INetSession; CHttpConnection* pHttpServer=NULL; CHttpFile* pHttpFile=NULL; try { INetSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT , 120*1000); INetSession.SetOption(INTERNET_OPTION_DATA_SEND_TIMEOUT , 120*1000); INetSession.SetOption(INTERNET_OPTION_DATA_RECEIVE_TIMEOUT , 120*1000); INetSession.SetOption(INTERNET_OPTION_CONTROL_SEND_TIMEOUT , 120*1000); INetSession.SetOption(INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, 120*1000); pHttpServer= INetSession.GetHttpConnection(m_strServerIp); //IP地址 pHttpFile= pHttpServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, szServreName, NULL, 1, NULL, NULL, INTERNET_FLAG_DONT_CACHE); // TRACE(szServreName); SetDlgItemText(IDC_STATIC_MESSAGE,"向服务起提出发送请求....."); if (!pHttpFile->SendRequestEx(nFileLen)) { if (pHttpFile!=NULL) { pHttpFile->Close(); delete pHttpFile; } if ( pHttpServer!=NULL) { pHttpServer->Close(); delete pHttpServer; } INetSession.Close(); MessageBox("向服务器发送请求失败!","错误", MB_OK|MB_ICONERROR); INetSession.Close(); return false; } SetDlgItemText(IDC_STATIC_MESSAGE,"开始向服务器发送数据....."); pHttpFile->Write(szSend,nFileLen); //将读取到的数据发送出去 SetDlgItemText(IDC_STATIC_MESSAGE,"发送完毕,正在结束发送....."); if (!(pHttpFile->EndRequest())) { if (pHttpFile!=NULL) { pHttpFile->Close(); delete pHttpFile; } if ( pHttpServer!=NULL) { pHttpServer->Close(); delete pHttpServer; } INetSession.Close(); MessageBox("结束传送请求失败", "错误", MB_OK|MB_ICONERROR); INetSession.Close(); return false; } SetDlgItemText(IDC_STATIC_MESSAGE,"正在获取服务器返回信息....."); nFileLen= pHttpFile->Read(cReceive,sizeof(cReceive)); strcat(szRecv,cReceive); if (nFileLen==0) { if (pHttpFile!=NULL) delete pHttpFile; if ( pHttpServer!=NULL) delete pHttpServer; INetSession.Close(); MessageBox("服务器未返回信息!","错误信息",MB_OK|MB_ICONERROR); return false; } SetDlgItemText(IDC_STATIC_MESSAGE,"已获取服务器返回信息,正在处理....."); } 今天最后一天在这里上班,散分祝福自己在新的单位事业有成,辉煌腾达~~~~~~您的祝福是我成就的动力来源!!!!!! 在FormView里何时初始化以及释放COM组件比较合适? 婉如小姐怎么还没当上斑竹阿? GetWindowLong的具体含义 UpdateDate()怎么用啊! combo box 的问题 这里问下,还有多少人搞MFC呢? 线程的参数可不可以改变 如何计算窗体可显示多少行字?看我做的那里有问题???请关注!!!!!!!!!! The simple,the best! ■■■有人知道LPC线性预测编码算法■■■ 很简单的问题?
IE 访问头部:GET /1.asp?id=323432 HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)
Host: www.hch.com
Connection: Keep-Alive
.
CHttpConnection* pHttpServer=NULL;
CHttpFile* pHttpFile=NULL;
try
{
INetSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT , 120*1000);
INetSession.SetOption(INTERNET_OPTION_DATA_SEND_TIMEOUT , 120*1000);
INetSession.SetOption(INTERNET_OPTION_DATA_RECEIVE_TIMEOUT , 120*1000);
INetSession.SetOption(INTERNET_OPTION_CONTROL_SEND_TIMEOUT , 120*1000);
INetSession.SetOption(INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, 120*1000);
pHttpServer= INetSession.GetHttpConnection(m_strServerIp); //IP地址
pHttpFile= pHttpServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,
szServreName,
NULL,
1,
NULL,
NULL,
INTERNET_FLAG_DONT_CACHE); // TRACE(szServreName); SetDlgItemText(IDC_STATIC_MESSAGE,"向服务起提出发送请求.....");
if (!pHttpFile->SendRequestEx(nFileLen))
{
if (pHttpFile!=NULL)
{
pHttpFile->Close();
delete pHttpFile;
}
if ( pHttpServer!=NULL)
{
pHttpServer->Close();
delete pHttpServer;
}
INetSession.Close();
MessageBox("向服务器发送请求失败!","错误", MB_OK|MB_ICONERROR);
INetSession.Close();
return false;
}
SetDlgItemText(IDC_STATIC_MESSAGE,"开始向服务器发送数据....."); pHttpFile->Write(szSend,nFileLen); //将读取到的数据发送出去
SetDlgItemText(IDC_STATIC_MESSAGE,"发送完毕,正在结束发送.....");
if (!(pHttpFile->EndRequest()))
{
if (pHttpFile!=NULL)
{
pHttpFile->Close();
delete pHttpFile;
}
if ( pHttpServer!=NULL)
{
pHttpServer->Close();
delete pHttpServer;
}
INetSession.Close();
MessageBox("结束传送请求失败", "错误", MB_OK|MB_ICONERROR);
INetSession.Close();
return false;
}
SetDlgItemText(IDC_STATIC_MESSAGE,"正在获取服务器返回信息.....");
nFileLen= pHttpFile->Read(cReceive,sizeof(cReceive)); strcat(szRecv,cReceive);
if (nFileLen==0)
{
if (pHttpFile!=NULL) delete pHttpFile;
if ( pHttpServer!=NULL) delete pHttpServer;
INetSession.Close();
MessageBox("服务器未返回信息!","错误信息",MB_OK|MB_ICONERROR);
return false;
}
SetDlgItemText(IDC_STATIC_MESSAGE,"已获取服务器返回信息,正在处理....."); }