⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 使用socket api如何与web服务器通信.htm

📁 photo.163.com 相册下载器 多线程下载
💻 HTM
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>月光软件站 - 编程文档 - Delphi - 使用Socket API如何与WEB服务器通信</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="keywords" content="Delphi,使用Socket API如何与WEB服务器通信,编程,文章,下载">
<meta name="description" content="使用Socket API如何与WEB服务器通信">
</head>
<body>
<center><script type="text/javascript" src="../top.js"></script></center>
<div id="header" align="center">
  <center>
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="750">
    <tr>
      <td width="100%">您的位置:<a href="../">首页</a>-> <a href="index.htm">编程文档</a>-> <a href="2_1.htm">Delphi</a>-> 使用Socket API如何与WEB服务器通信</td>
    </tr>
  </table>
  </center>
</div>
<div id="main" align="center">
  <center>
<table border="0" width="750" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111">
  <tr>
    <td width="165" valign="top">
         <table bgColor="#F4F4F4" border="0" cellPadding="0" cellSpacing="0" width="165" style="border-collapse: collapse" height="100%">
  <tr>
    <td width="100%" valign="top">
      <table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse" width="100%">
        <tr>
          <td width="100%" bgcolor="#000000">
          <p align="center">
          <b><font color="#FFFFFF">Delphi</font></b></td>
        </tr>
        <tr>
          <td width="100%"><p align="center"></td>
        </tr>
        <tr>
          <td width="100%" bgcolor="#000000">
          <p>
          <img border="0" src="images/d_1.gif" align="middle" width="13" height="13"><font color="#FFFFFF"> 本类阅读TOP10</font></td>
        </tr>
        <tr>
          <td width="100%">
·<a href="44543.htm">分布式网络考试系统原型分析及实现</a><br>·<a href="44504.htm">游戏外挂设计技术探讨①</a><br>·<a href="43027.htm">使用HOOK随心监视Windows</a><br>·<a href="44956.htm">Delphi 水晶报表打包解决</a><br>·<a href="45038.htm">试题库开发中非文本数据的处理</a><br>·<a href="44952.htm">如何将几个DBGRID里的内容导入同一个EXCEL表中....的问题</a><br>·<a href="51506.htm">如何使用Delphi设计强大的服务器程序</a><br>·<a href="45037.htm">工人线程中关闭窗体的实现</a><br>·<a href="51512.htm">用DLL方式封装MDI子窗体。</a><br>·<a href="44868.htm">支持XP下托盘栏气球提示的托盘单元</a><br>
</td>
        </tr>
      </table>
      <br>
        <table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse" width="100%">
        <tr>
          <td width="100%" bgcolor="#111111">
          <font color="#FFFF00">→</font> 
          <font color="#FFFFFF">分类导航</font></td>
        </tr>
        <tr>
          <td width="100%">

		  <table border=0 cellpadding=0 cellspacing=3 width=99%>
<tr align=center><td width='50%'><a href="1_1.htm"><font color="#000000">VC语言</font></a></td><td width='50%'><a href="2_1.htm"><font color="#000000">Delphi</font></a></td></tr><tr align=center><td width='50%'><a href="3_1.htm"><font color="#000000">VB语言</font></a></td><td width='50%'><a href="4_1.htm"><font color="#000000">ASP</font></a></td></tr><tr align=center><td width='50%'><a href="5_1.htm"><font color="#000000">Perl</font></a></td><td width='50%'><a href="6_1.htm"><font color="#000000">Java</font></a></td></tr><tr align=center><td width='50%'><a href="7_1.htm"><font color="#000000">Script</font></a></td><td width='50%'><a href="8_1.htm"><font color="#000000">数据库</font></a></td></tr><tr align=center><td width='50%'><a href="9_1.htm"><font color="#000000">其他语言</font></a></td><td width='50%'><a href="10_1.htm"><font color="#000000">游戏开发</font></a></td></tr><tr align=center><td width='50%'><a href="11_1.htm"><font color="#000000">文件格式</font></a></td><td width='50%'><a href="12_1.htm"><font color="#000000">网站制作</font></a></td></tr><tr align=center><td width='50%'><a href="13_1.htm"><font color="#000000">软件工程</font></a></td><td width='50%'><a href="14_1.htm"><font color="#000000">.NET开发</font></a></td></tr>
		  </table>

		  <table border=0 cellpadding=0 cellspacing=3 width=99%>
		  <tr align=center><td>
		  <form action="search.asp"><input name="k" size="12" style="border: 1px dotted #42a5f7;"> <input src="images/d_search.gif" type="image" value="submit" align="absmiddle" border="0"><input name="type" type="hidden" value="info"></form>
		  </td></tr>
		  </table>
		  <script type="text/javascript" src='/download/ads/js_ads_left.js'></script>

		  </td>
        </tr>
      </table>
  </tr>
  </table>
     
    </td>
    <td width=8 bgColor=#ffffff  background="images/bg_shadow.gif" valign="top"></td>
    <td width="595" valign="top" height="2">
<table border="0" cellpadding="0" cellspacing="0" style="TABLE-LAYOUT: fixed;border-collapse: collapse" width="100%">
  <tr>
    <td class=article_title align=middle height=30>
    <b>使用Socket API如何与WEB服务器通信</b></td>
  </tr>
  <tr>
    <td align="middle" width="100%" bgColor="#888888" height="1"></td>
  </tr>
  <tr>
    <td width="100%" height="2"></td>
  </tr>
  <tr>
    <td width="100%" height="38">
    <p align="center"><B>作者</B>:未知  <B>来源</B>:月光软件站<!--未知-->  <B>加入时间</B>:2005-6-5 月光软件站</td>
  </tr>
  <tr>
    <td width="100%" valign="top"><p>今天看到了有一些人在讨论如何使用Socket API与WEB服务器进行通信.</p><p>其实这个问题只要将请求网页HTTP内容明白就好解决.</p><p>请求HTTP头内容如下:</p><p>GET&nbsp;<a href="http://www.paymesurf.com/surf3.php?usrid=607">你的网址</a> HTTP/1.1&nbsp;&nbsp; </p><p>Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*&nbsp; //要求返回的内容,如需要返回图片或Flash等,我通常都是让服务器仅返回text/html,主要是加快速度.</p><p>Accept-Language: zh-cn&nbsp;&nbsp; //使用的语言</p><p>User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; MyIE2) //这里主要是告诉服务器你的IE版号,所使用的系统及使用的浏览器,其实如果你想隐藏这里的内容,可以自行修改.</p><p>Host: <font color="#002c99"><a href="http://www.paymesurf.com">www.paymesurf.com</a> //服务器地址</font></p><p>Proxy-Connection: Keep-Alive&nbsp; </p><p>上面基本上是HTTP的内容,在使用过程中大家需要注意以下几点:</p><p>1 发送请求的内容时,一定要再多加一个+#13#10</p><p>&nbsp;&nbsp;&nbsp; Httpstr:='GET <a href="http://www.paymesurf.com/surf3.php?usrid=607"><font color="#002c99">http://www.paymesurf.com:80/surf3.php?usrid=607</font></a> HTTP/1.1'+#13#10;<br/>&nbsp;&nbsp;&nbsp; httpstr:=httpstr+'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*'+#13#10;<br/>&nbsp;&nbsp;&nbsp; httpstr:=httpstr+'Accept-Language: zh-cn'+#13#10;<br/>&nbsp;&nbsp;&nbsp; httpstr:=httpstr+'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; MyIE2; .NET CLR 1.1.4322)'+#13#10;<br/>&nbsp;&nbsp;&nbsp; httpstr:=httpstr+'Host: <a href="http://www.paymesurf.com'+/#13#10"><font color="#002c99">www.paymesurf.com'+#13#10</font></a>;<br/>&nbsp;&nbsp;&nbsp; httpstr:=httpstr+'Proxy-Connection: Keep-Alive'+#13#10;</p><p>上面是一个网友的请求内容,而这个无法返回网页内容,主要问题就是没有告诉服务器哪里是结束位置.需要在最后面的位置再加入一个+#13#10,这样服务器 就会知道这里是结束了.</p><p>2 如何知道网页请求完毕,主要是通过FD_CLOSE来判断,当网页全部返回时,服务器会自动关闭这个请求,所以你只要知道当前请求关闭就说明网页已经下载完毕.</p><p>3 下面是我个人的经验了,如果你想写与WEB通信的软件,最好不要直接使用Socket与服务器通信,先将自己的IE设置成代理的模式,先看一看IE是如何通过代理软件(这个软件你最好自己写一个,可以显示请求的内容的.)工作的.然后你再使用你的软件与服务器通信这样你就知道你通常出错在哪里了.</p><p></p><p>以上是我这段时间研究的内容.希望大家多拍砖.</p><img border="0" src="down_info.asp?id=51416" width="1" height="1"><br><br></td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#CCCCCC" height="1"></td>
  </tr>
  <tr>
    <td width="100%"><br><b>相关文章</b>:<p><b>相关软件</b>:</td>
  </tr>
  </table>
     </td>
  </tr>
</table>
  </center>
</div>
<center><script type="text/javascript" src="../bottom.js"></script></center>
</body>
</html><div align="center" id="objbottom"><center>

<script type="text/javascript"> 
var arrBaiduCproConfig=new Array(); 
arrBaiduCproConfig['uid'] =43125;
arrBaiduCproConfig['n'] ='williamlongcpr';
arrBaiduCproConfig['tm'] =20;
arrBaiduCproConfig['cm'] =76;
arrBaiduCproConfig['um'] =26;
arrBaiduCproConfig['w'] =728;
arrBaiduCproConfig['h'] =90;
arrBaiduCproConfig['wn'] =4;
arrBaiduCproConfig['hn'] =1;
arrBaiduCproConfig['ta'] ='right';
arrBaiduCproConfig['tl'] ='bottom';
arrBaiduCproConfig['bu'] =0;
arrBaiduCproConfig['bd'] ='#003300';
arrBaiduCproConfig['bg'] ='#ffffff';
arrBaiduCproConfig['tt'] ='#000000';
arrBaiduCproConfig['ct'] ='#000000';
arrBaiduCproConfig['url'] ='#000000';
arrBaiduCproConfig['bdl'] ='#003300';
arrBaiduCproConfig['rad'] =1;
</script> 
<script type="text/javascript" src="http://cpro.baidu.com/cpro/ui/ui.js" > 
</script> 
<script type="text/javascript"> 
<!-- 
document.write(baiduCproIFrame()); 
--> 
</script>                         
                          
                          
</center></div>

<script type="text/javascript" >
document.write ('<style type="text/css">#objbottom {position:absolute}</style>');
var obj=document.getElementById("objbottom");
self.onError=null;
currentX = 0;  
currentY = 0;
whichIt = null;           
lastScrollX = 0; lastScrollY = 0;
obj.style.left = (document.body.clientWidth - 730) / 2;
obj.style.top = document.body.clientHeight - 90;
function moveObj() {
  diffY = document.body.scrollTop; 
  diffX = 0; 
  if(diffY != lastScrollY) {
    percent = .1 * (diffY - lastScrollY);
    if(percent > 0) percent = Math.ceil(percent);
    else percent = Math.floor(percent);
    document.all.objbottom.style.pixelTop += percent;
    lastScrollY = lastScrollY + percent;
  }
  if(diffX != lastScrollX) {
    percent = .1 * (diffX - lastScrollX);
    if(percent > 0) percent = Math.ceil(percent);
    else percent = Math.floor(percent);
    document.all.objbottom.style.pixelLeft += percent;
    lastScrollY = lastScrollY + percent;
  }  
}  
action = window.setInterval("moveObj()",1);
</script>




<br><br><br>
<div align="center"><center>
  <table cellspacing="0" cellpadding="1" border="0" width="770" style="font-size: 9pt;" >
    <tr><td width="770" bgcolor="#000000" height="1"></td></tr>
    <tr><td width="770" height="5"></td></tr>
    <tr>
      <td align="center" width="770">
	  <a href="/" target="_top">月光软件</a>┊<a href="/download/" target="_top">程序下载</a>┊<a href="/doc/" target="_top">编程文档</a>┊<a href="/book/" target="_top">电脑教程</a>┊<a href="/web/" target="_top">网站设计</a>┊<a href="/site/" target="_top">网址导航</a>┊<a href="/art/" target="_top">网络文学</a>┊<a href="/game/" target="_top">游戏天地</a>┊<a href="/joke/" target="_top">幽默笑话</a>┊<a href="/life/" target="_top">生活休闲</a>┊<a href="/picture/" target="_top">美女图片</a>┊<a href="/guestbook/" target="_top">意见反馈</a><br>
<a href="/program/bbs/docelite1105.htm">电脑技术</a>┊<a href="/program/bbs/docelite405353.htm">编程开发</a>┊<a href="/program/bbs/docelite25188.htm">网络专区</a>┊<a href="/program/bbs/docelite10811.htm">谈天说地</a>┊<a href="/program/bbs/docelite113108.htm">情感世界</a>┊<a href="/program/bbs/docelite872697.htm">游戏元素</a>┊<a href="/program/bbs/docelite50820.htm">分类游戏</a>┊<a href="/program/bbs/docelite166458.htm">热门游戏</a>┊<a href="/program/bbs/docelite42994.htm">体育运动</a>┊<a href="/program/bbs/docelite872698.htm">手机专区</a>┊<a href="/program/bbs/docelite28075.htm">业余爱好</a>┊<a href="/program/bbs/docelite34403.htm">影视沙龙</a>
<br>
<a href="/program/bbs/docelite872701.htm">音乐天地</a>┊<a href="/program/bbs/docelite872702.htm">数码广场</a>┊<a href="/program/bbs/docelite121902.htm">教育园地</a>┊<a href="/program/bbs/docelite872703.htm">科学大观</a>┊<a href="/program/bbs/docelite991826.htm">古今纵横</a>┊<a href="/program/bbs/docelite49868.htm">谈股论金</a>┊<a href="/program/bbs/docelite55064.htm">人文艺术</a>┊<a href="/program/bbs/docelite165391.htm">医学保健</a>┊<a href="/program/bbs/docelite115338.htm">动漫图酷</a>┊<a href="/program/bbs/docelite872704.htm">二手专区</a>┊<a href="/program/bbs/docelite112364.htm">地方风情</a>┊<a href="/program/bbs/docelite165368.htm">各行各业</a>
      <br><br>
      <a href="/">月光软件站</a>·<a href="/sitemap.htm" target="_blank">版权所有</a>
	</td></tr>
  </table>
</center></div>
<br><br><br><br><br><br>


<!--  */  //-->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -