概述
在C#中经常会用到Socket去接收和发送数据,而且也是非常方便的,有时候我们会向服务端去请求数据,如果返回的数据量很大,比如超过10M甚至是更多,那么该怎样去接收数据呢?下面以一个在项目中用到的实例去分析和解释这个问题,先看看下面的这段代码?
/// <summary> /// 返回摄像头信息 /// </summary> private void RcvCameraInfos(object obj) { string sourceIp = System.Configuration.ConfigurationSettings.AppSettings["SourceIP"].ToString(); string sourcePort = System.Configuration.ConfigurationSettings.AppSettings["SourcePort"].ToString(); Socket mysocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(sourceIp), int.Parse(sourcePort)); mysocket.Connect(ipEndPoint); DateTime start = DateTime.Now; string s = "<?xml version="1.0" ?>"; s += "<info name="getcameracodematrixtable"/>