高性能TcpServer(C#) - 1.网络通信协议

高性能TcpServer(C#) - 2.创建高性能Socket服务器SocketAsyncEventArgs的实现(IOCP)

高性能TcpServer(C#) - 3.命令通道(处理:掉包,粘包,垃圾包)

高性能TcpServer(C#) - 4.文件通道(处理:文件分包,支持断点续传)

高性能TcpServer(C#) - 5.客户端管理

高性能TcpServer(C#) - 6.代码下载

应用场景

升级程序

流程:终端->查询服务器版本比较->升级程序(获取包数,获取各包数据)->数据拼装生成文件->最后更新服务器上该设备的版本信息

分包代码段:

static Dictionary<int, string> ReadFile(string path)

{

Dictionary<int, string> dicFileData = new Dictionary<int, string>();

FileStream fs = new FileStream(path, FileMode.Open);

BinaryReader binReader = new BinaryReader(fs);

int bagindex = 1;

int dataindex = 0;

byte[] bBuffer = new byte[fs.Length];

int bagsize = 235;// 一包数据大小

byte[] temp = new byte[bagsize];

binReader.Read(bBuffer, 0, (int)fs.Length);

for (int i = 0; i < bBuffer.Length; i++)

{

if ((bagsize - 1) == dataindex || (bBuffer.Length - 1) == i)

{

if ((bBuffer.Length - 1) == i) temp[dataindex++] = bBuffer[i];

string data = CCommonFunc.ToHexString(temp, dataindex, false);

dicFileData.Add(bagindex, data);

bagindex++;

dataindex = 0;

temp = new byte[bagsize];

}

temp[dataindex++] = bBuffer[i];

}

binReader.Close();

fs.Close();

return dicFileData;

}

测试:

最新文章

  1. Dynamics CRM 之ADFS 使用 WID 的联合服务器场
  2. 利用Python进行数据分析(3) 使用IPython提高开发效率
  3. &quot;_OBJC_CLASS_$_CMMotionManager&quot;, referenced from:
  4. JAVA中取余(%)规则和介绍
  5. 【wikioi】1553 互斥的数(hash+set)
  6. DataBase: MySQL在.NET中的应用
  7. 属性的定义以及@synthesize的使用
  8. Iframe的应用以及父窗口和子窗口的相互访问
  9. 改变navigationbar 标题颜色
  10. Ubuntu 怎么在右键添加打开终端
  11. python代码风格规范
  12. 【HTML】模板
  13. TP框架设置的LOG_LEVEL不起作用
  14. 转:rabbitMQ 安装与管理
  15. Maven插件一览
  16. Entity Framework Core系列之实战(ASP.NET Core MVC应用程序)
  17. apache2.4 文件浏览服务器页面配置
  18. nginx-fastcgi 第九章
  19. C++中的getline()
  20. yocto-sumo源码解析(二): oe-buildenv-internal

热门文章

  1. oracle 死锁 锁
  2. 提升ML.NET模型的准确性
  3. JSON理解(一篇就够了)
  4. easyui三
  5. 16.Java基础_对象内存图
  6. HTML与CSS学习笔记(4)
  7. TeamyinyinFish-&gt;鱼嘤嘤小分队软件工程beta迭代作业
  8. 【转】阿里云部署java web项目
  9. Spring配置文件中的那些标签
  10. 解决Python开发中,Pycharm中无法使用中文输入法问题