通常的手段有什么?顺序号?计时器?确认?各自具体的实现是怎样的?如能有源码更佳!

解决方案 »

  1.   

    send packet时加头,通常用一个struct,有packet 的序号,checksum,
    如果是point to point,可以用一问一答的形式。但这样就不如用tcp啦。
    通常udp用在广播,多播(如视频)等
      

  2.   

    Add a DWORD sequence number varible to both Client and Sever! 
    When Client sends Server a package ,It should send the sequence number also.
    And the server check the sequence number,if it is not the next sequence number
    .Send message to client for resend to package.
      

  3.   

    The Adaptive File Distribution Protocol (AFDP) may suit your needs
    AFDP uses UDP to send files to a group of hosts (where a group can
    contain 1 host, or a very large number of hosts). AFDP supports multicast,
    broadcast and unicast file transfers, and uses a rate-based flow control
    scheme to prevent over-running the receivers.The source code for AFDP is available via anonymous ftp from:
            ftp.ecf.toronto.edu:/pub/afdp/More information is available on the AFDP web page,
            url http://www.ecf.toronto.edu/afdp/
      

  4.   

    找本tcp原理的书看看三次握手不就行了吗?
      

  5.   

    要可靠传输用TCP就可以了,为什么要用UDP?
      

  6.   

    同意楼上的所说的,UDP本身就是不可靠的,要可靠的就用TCP就行了
      

  7.   

    用UDP自有它的道理
    哈哈,别再告诉我用TCP了
      

  8.   

    简单的方法就是用停等协议了,按序号接收比如收到序号为10时的包那么下一个包的序号就必须是11,这个最简单我相信你肯定能自己实现的
    如果是想实现类似TCP的样子很困难,程序的工作量非常的大而且有的地方并不好作。
    系统都是在内核层来完成的,如果在应用层完成难度很大。
    你可以看一下滑动窗口的算法,
    特别是定时器很难处理
    我也做过类似的东西不过没有成功希望你能成功
      

  9.   

    谢谢 wisemanboy ,我尽力
      

  10.   

    wisemanboy说的对 
    要想实现可靠的UDP传输无疑于实现TCP协议。
    在TCP—IP详解卷三中的第一章对UDP实现可靠传输有比较详细的理论说明,但没有源代码。楼主,如果找到相应的代码请给我一份 谢谢![email protected]
      

  11.   

    fengge8ylf :
    若找到我会给你的,但有人能给我吗?
      

  12.   

    谢谢 windows_editor 的代码!!