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

📄 symbian 2nd支持cmnet和cmwap的断点续传的rsocket实现.htm

📁 一个symbian下的多线程下载程序和文档。
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0048)http://www.cublog.cn/u/26691/showart_459698.html -->
<HTML><HEAD><TITLE>symbian 2nd支持cmnet和cmwap的断点续传的RSocket实现 - 手机开发 - chenwayne</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gbk"><LINK 
href="symbian 2nd支持cmnet和cmwap的断点续传的RSocket实现.files/index.css" 
rel=stylesheet></LINK><LINK title="ChinaUnix Blog RSS Feed" 
href="http://blog.chinaunix.net/u/rss.php?id=26691" type=application/rss+xml 
rel=alternate></LINK>
<META content="symbian 2nd支持cmnet和cmwap的断点续传的RSocket实现 - 手机开发 - chenwayne" 
name=keywords>
<META 
content="中国最大的IT技术博客-ChinaUnix博客:symbian 2nd支持cmnet和cmwap的断点续传的RSocket实现 - 手机开发 - chenwayne" 
name=description>
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY style="BACKGROUND: #c7c7c7" leftMargin=0 topMargin=0 align="center" 
marginheight="0" marginwidth="0">
<TABLE style="BORDER-COLLAPSE: collapse; HEIGHT: 25px" height=25 cellSpacing=0 
cellPadding=0 width=760 align=center 
background="symbian 2nd支持cmnet和cmwap的断点续传的RSocket实现.files/tophem1.gif" 
  border=0><TBODY>
  <TR>
    <TD id=tool-bar noWrap align=left>&nbsp; <A 
      href="http://blog.chinaunix.net/" target=_blank>博客首页</A> <A 
      href="http://blog.chinaunix.net/register.php" target=_blank>注册</A> <A 
      href="http://bbs.chinaunix.net/forumdisplay.php?fid=51" 
      target=_blank>建议与交流</A> <A href="http://blog.chinaunix.net/top/" 
      target=_blank>排行榜</A> <A 
      onclick="NewWindows('http://www.cublog.cn/addlink.php?url='+location.href+'&amp;title='+document.title);return false;" 
      href="http://www.cublog.cn/u/26691/" target=_blank>加入友情链接</A> </TD>
    <FORM id=loginForm action=/search.php method=get target=_blank>
    <TD noWrap align=right><IMG id=starimg height=12 alt="" 
      src="symbian 2nd支持cmnet和cmwap的断点续传的RSocket实现.files/userstar.gif" width=55 
      border=0> <A id=star title=给此博客推荐值 
      onclick="NewWindows(this.href);return false;" 
      href="http://www.cublog.cn/u2/star.php?blogid=26691">推荐</A> <A 
      id=complaint title=投诉此博客 onclick="NewWindows(this.href);return false;" 
      href="http://www.cublog.cn/u2/complaint.php?blogid=26691">投诉</A> 搜索:<INPUT 
      name=q> <INPUT class=button1 type=submit value=搜索> <A 
      href="http://www.cublog.cn/help/">帮助</A></TD></FORM></TR></TBODY></TABLE>
<SCRIPT language=javascript><!--navHover = function() {var lis = document.getElementById("navmenu").getElementsByTagName("LI");for (var i=0; i<lis.length; i++) {lis[i].onmouseover=function() {this.className+=" iehover";}lis[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" iehover\\b"), "");}}}function NewWindows(shref){var xx=(window.screen.width-450)/2;var yy=(window.screen.height-200)/2;pp=window.open(shref,"win","menubar=no,location=no,resizable=no,scrollbars=no,status=no,left="+xx+",top="+yy+",Width=450,Height=200");}function $(s){return document.getElementById(s);}//--></SCRIPT>

<TABLE 
style="BACKGROUND-IMAGE: url(http://www.cublog.cn/templates/newdefault/images/bg_top.gif); BORDER-COLLAPSE: collapse" 
height=130 cellSpacing=0 cellPadding=0 width=760 align=center bgColor=#ecfdfd 
border=0>
  <TBODY>
  <TR>
    <TD align=middle width=500>
      <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#2870c7 cellSpacing=0 
      cellPadding=0 border=1>
        <TBODY>
        <TR>
          <TD bgColor=#ecfdfd>
            <P style="MARGIN: 5px; LINE-HEIGHT: 150%"><FONT 
            style="FONT-SIZE: 14px" color=#1e8dc5><B>chenwayne 
            </B></FONT></P>放弃该放弃的是无奈,放弃不该放弃的是无能;不放弃该放弃的是无知,不放弃不该放弃的却是执着。。。</TD></TR></TBODY></TABLE></TD>
    <TD width=260></TD></TR></TBODY></TABLE>
<TABLE style="BORDER-COLLAPSE: collapse" height=27 cellSpacing=0 cellPadding=0 
width=760 align=center bgColor=#c3ddf6 border=0>
  <TBODY>
  <TR>
    <TD align=middle><A class=list1 href="http://chenwayne.cublog.cn/" 
      target=_blank>chenwayne.cublog.cn</A> </TD>
    <TD style="COLOR: #2a5200" align=right width=620>
      <UL id=navmenu>
        <LI class=ul0><A class=list1 href="http://control.cublog.cn/" 
        target=_blank>管理博客</A> </LI>
        <LI class=ul0><A class=list1 
        href="http://control.cublog.cn/article_new.php" target=_blank>发表文章</A> 
        </LI>
        <LI class=ul0 style="WIDTH: 40px"><A class=list1 
        href="http://www.cublog.cn/u/26691/guestbook.html">留言</A> </LI>
        <LI class=ul0><A class=list1 
        href="http://www.cublog.cn/u/26691/links.html">收藏夹</A> <!-- 0 --></LI>
        <LI class=ul0><A class=list1 
        href="http://www.cublog.cn/u/26691/group.html">博客圈</A> </LI>
        <LI class=ul0 style="WIDTH: 40px"><A class=list1 
        href="http://www.cublog.cn/u/26691/music.html">音乐</A> <!-- 0 --></LI>
        <LI class=ul0 style="WIDTH: 40px"><A class=list1 
        href="http://www.cublog.cn/u/26691/photo.html">相册</A> <!-- 0 --></LI>
        <LI class=ul0 style="WIDTH: 40px"><A class=list1 
        href="http://www.cublog.cn/u/26691/article.html">文章</A> 
        <UL class=ul1>
          <LI><A href="http://www.cublog.cn/u/26691/article_59380.html">· 心情随笔<!-- a59380 --></A><!-- 59380 --> 
          <LI><A href="http://www.cublog.cn/u/26691/article_42621.html">· 视频探索<!-- a42621 --></A><!-- 42621 --> 
          <LI><A href="http://www.cublog.cn/u/26691/article_42622.html">· 手机开发<!-- a42622 --></A><!-- 42622 --> 
          <LI><A href="http://www.cublog.cn/u/26691/article_42623.html">· 
          linux备忘录<!-- a42623 --></A><!-- 42623 --> 
          <LI><A href="http://www.cublog.cn/u/26691/article_75762.html">· PSP开发<!-- a75762 --></A><!-- 75762 --> </LI></UL></LI>
        <LI class=ul0 style="WIDTH: 40px"><A class=list1 
        href="http://www.cublog.cn/u/26691/index.html">首页</A> </LI></UL></TD>
    <TD width=2></TD></TR></TBODY></TABLE>
<SCRIPT language=javascript>function $(s){return document.getElementById(s);}function ShowHideDiv(divid,iImg){if($(divid).style.display == "none"){iImg.src="../../templates/newdefault/images/dot2.gif";$(divid).style.display = "block";iImg.title="收起";}else{iImg.src="../../templates/newdefault/images/dot4.gif";$(divid).style.display = "none";iImg.title="展开";}}navHover();</SCRIPT>

<TABLE style="BORDER-COLLAPSE: collapse; WORD-WRAP: break-word" cellSpacing=0 
cellPadding=0 width=760 align=center bgColor=#ffffff border=0>
  <TBODY>
  <TR>
    <TD align=middle height=30><FONT style="FONT-SIZE: 14pt" 
      color=#02368d><B>symbian 
  2nd支持cmnet和cmwap的断点续传的RSocket实现</B></FONT><BR></TD></TR>
  <TR>
    <TD align=middle height=9><IMG height=9 alt="" 
      src="symbian 2nd支持cmnet和cmwap的断点续传的RSocket实现.files/right_line.gif" 
      width=502 border=0></TD></TR>
  <TR>
    <TD align=middle>
      <TABLE style="BORDER-COLLAPSE: collapse; WORD-WRAP: break-word" 
      cellSpacing=0 cellPadding=0 width=740 border=0>
        <TBODY>
        <TR>
          <TD width=740>
            <DIV id=art style="MARGIN: 15px" width="560">
            <DIV>北京理工大学&nbsp; 20981&nbsp; 陈罡</DIV>
            <DIV>记得以前曾经写过关于断点续传的文章,只是举例了win32环境下c++实现的单线程断点续传的实现方法和代码。现在时间比较充裕了,就把symbian 
            2nd下面实现的断点续传代码拿出来晒晒,希望能起到抛砖引玉的效果,更加促进这个底层模块的稳定性和兼容性。</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>现在就把nettest这个symbian 2nd程序各个部分展开来分析一下:</DIV>
            <DIV>nettest总体上来讲分为两部分组成,一个是常规的s60的ui相关的框架,一个是netcore支持断点续传的下载模块。s60的ui相关框架部分包括NetTestApp.cpp, 
            NetTestAppUi.cpp, NetTestContainer.cpp, 
            NetTestDocument.cpp这些文件都是sdk的向导自动生成的文件,无需多说;netcore部分从逻辑上来看,应该分为两个部分,一个是常规的基于RSocket的socket 
            engine引擎部分,一个是M5HttpDown支持断点续传下载的模块。其中的socket engine只是从nokia 
            sdk中的sockets 
            demo中提取出来的代码,其本身基本上跟demo里面的socket引擎一致;另外的M5HttpDown的断点续传的代码则是实现断点续传的关键之所在了。</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>下面就是代码的内容和简要的分析:</DIV>
            <DIV>M5HttpDown.h头文件的定义---&gt;</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>#ifndef _M5_HTTP_DOWN_H_<BR>#include 
            &lt;e32std.h&gt;<BR>#include &lt;e32base.h&gt;<BR>#include 
            "socketsengine.h" // 就是普通的sockets engine了<BR>#include 
            "uinotifier.h"&nbsp;&nbsp;&nbsp; // 
            uinotifier是用来在屏幕上输出一些状态的虚基类<BR>#include "m5httpdownnotifier.h" // 
            收到真实的数据后进行回调的虚基类</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>#define 
            HTTP_WEB_PORT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            80<BR>#define 
            HTTP_TEMP_BUF_LEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            120<BR>#define 
            HTTP_SEND_BUF_LEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
256</DIV>
            <DIV>#define HTTP_DOWN_CMWAP&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 
            // 定义接入点的类型,使用cmwap方式断点续传还是cmnet方式<BR>#define 
            HTTP_DOWN_CMNET&nbsp;&nbsp;&nbsp; 1</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>// 一些常量定义,用于解析服务器返回过来的数据头</DIV>
            <DIV>_LIT8(KHttpRespOK,&nbsp;&nbsp;&nbsp; "200 OK") ; </DIV>
            <DIV>&nbsp;</DIV>
            <DIV>// 
            呵呵,这里就是移动恶心的地方了,这个Content-length通过10.0.0.172返回的竟然是小写的length</DIV>
            <DIV>// 而通过cmnet返回的则是正常的大写的Length,这里我偷懒定义了两次,其实可以Upper()一下,统一</DIV>
            <DIV>// 用一种方法来处理的。<BR>_LIT8(KHttpCMWapHdrFileLen, "Content-length: 
            ") ;<BR>_LIT8(KHttpCMNetHdrFileLen, "Content-Length: ") ; 
            <BR>_LIT8(KHttpClip,&nbsp;&nbsp;&nbsp; "/") ; 
            <BR>_LIT8(KHttpHdrDiv,&nbsp;&nbsp;&nbsp;&nbsp; "\r\n") ; 
            <BR>_LIT8(KHttpHdrEnd,&nbsp;&nbsp;&nbsp; "\r\n\r\n") ; 
            <BR>_LIT8(KHttpPrefix,&nbsp;&nbsp;&nbsp; "http://") ; 
            <BR>_LIT8(KHttpsPrefix,&nbsp;&nbsp;&nbsp; "https://") ; </DIV>
            <DIV>&nbsp;</DIV>
            <DIV>// 这里的CommonGet,是指不经过断点续传直接下载,虽然支持断点续传,但是第一次下载的时候,</DIV>
            <DIV>// 还什么文件都没有呢,不必要使用断点续传,直接按照常规的下载方式下载好了</DIV>
            <DIV>_LIT8(KHttpCommonGet1, "GET ") ; <BR>_LIT8(KHttpCommonGet2, " 
            HTTP/1.1\r\nUser-Agent: Nokia 7610\r\nHost: ") ; 
            <BR>_LIT8(KHttpCommonGet3,&nbsp; ":") ; <BR>_LIT8(KHttpCommonGet4, 
            "\r\nAccept: */*\r\nConnection: Keep-Alive\r\n\r\n") ;</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>// 这里才是真正的断点续传需要的定义了,需要指定RANGE的</DIV>
            <DIV>_LIT8(KHttpResumeGet1,&nbsp; "GET ") ; 
            <BR>_LIT8(KHttpResumeGet2,&nbsp; " HTTP/1.1\r\nUser-Agent: Nokia 
            7610\r\nHost: ") ; <BR>_LIT8(KHttpResumeGet3,&nbsp; ":") ; 
            <BR>_LIT8(KHttpResumeGet4,&nbsp; "\r\nAccept: */*\r\nRANGE: bytes=") 
            ; <BR>_LIT8(KHttpResumeGet5,&nbsp; "-\r\nConnection: 
            Keep-Alive\r\n\r\n") ; </DIV>
            <DIV>&nbsp;</DIV>

⌨️ 快捷键说明

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