04 2012 档案

摘要:View Code 1 using System; 2 using System.Net; 3 using System.Net.Sockets; 4 using System.ServiceProcess; 5 using System.Threading; 6 7 namespace TestUdpServer 8 { 9 // this class encapsulates a single packet that 10 // is either sent or received by a UDP socket 11 public clas... 阅读全文
posted @ 2012-04-09 09:23 garyChong 阅读(650) 评论(0) 推荐(1)
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 using System.Net.Sockets; 5 using System.Net; 6 using System.Threading; 7 using System.Runtime.InteropServices; 8 9 namespace ConsoleApplication2 10 { 11 class Program 12 { 13 static Socket m_sListen; 14 15 static... 阅读全文
posted @ 2012-04-07 13:56 garyChong 阅读(744) 评论(0) 推荐(1)
摘要:众所周知,UDP 就是用户数据报协议,在互联网参考模型的第四层——传输层。与TCP协议同层,都是提供信息的传输服务,但与TCP最大区别就是,它是一种无连接不可靠的信息传输。什么是无连接不可靠?直白点讲就是,发送数据的时候,直接把UDP包往网络一扔就完事了,接不接受收到发送的就不理了;接受数据的时候,有发给本地的UDP包就照单全收,收完再看是谁发的。相比TCP,少了握手建立连接,维护连接,连接释放等一系列过程,因此具有很小的资源消耗和处理速度快的优点。好了说了一堆废话,开始讲怎么利用C#中Socket进行UDP通信。TCP、UDP应用程序可以通过TCPClient、TCPListener 和 . 阅读全文
posted @ 2012-04-06 23:16 garyChong 阅读(1739) 评论(0) 推荐(1)