05 2010 档案

摘要:这篇文章本来是星期五晚写好了, 因6日去旅游了, 没来得急发上来 1. 同样, 我们先看看这一个比简单的 结构体 <!--<br/ /><br/ />Code highlighting produced by Actipro CodeHighlighter (freeware)<br/ />http 阅读全文
posted @ 2010-05-30 08:35 一浩瀚星空一 阅读(1059) 评论(0) 推荐(1) 编辑
摘要:今天我们来学 socket 发送结构体1. 先看要发送的结构体代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Runtime.InteropServices;namespaceLin.p2p.Mo{///<summary>///通信消息格式///</summary>[Se 阅读全文
posted @ 2010-05-28 17:55 一浩瀚星空一 阅读(2351) 评论(0) 推荐(1) 编辑
摘要:今天来写一个UPD1.服务端:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Net.Sockets;usingSystem.Net;namespaceConsoleApplication1{classProgram{staticvoidMain(string[]args){//1.创建套节字S 阅读全文
posted @ 2010-05-27 21:50 一浩瀚星空一 阅读(568) 评论(0) 推荐(1) 编辑
摘要:现在来传一个图片看看, 改改程序, 看看服务端图片为 140K, 1.jgp1. 服务端代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1usingSystem;2usingSystem.Collections.Generic;3usingSystem.Text;4usingSystem.Net.Sockets;5usingSystem.Net;6usingSystem.IO;78namespaceConsoleApplication19 阅读全文
posted @ 2010-05-26 22:48 一浩瀚星空一 阅读(389) 评论(0) 推荐(1) 编辑
摘要:1. 服务端程序Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1usingSystem;2usingSystem.Collections.Generic;3usingSystem.Text;4usingSystem.Net.Sockets;5usingSystem.Net;67namespaceConsoleApplication18{9classProgram10{11staticvoidMain(string[]args)12{13// 阅读全文
posted @ 2010-05-26 21:15 一浩瀚星空一 阅读(525) 评论(0) 推荐(0) 编辑
摘要:最近看到一个帖子,问的是怎么把自己定义的结构体转换成对应的byte数组,一般来说,都会想到用Marshal类来完成这个功能,其实还有一个方法也可以,那就是利用unsafe代码。 先定义假想的一个值类型: 然后,定义一个公用方法签名:Action<MyStruct, Stream>,这个是为了方便之后 阅读全文
posted @ 2010-05-25 17:03 一浩瀚星空一 阅读(521) 评论(0) 推荐(0) 编辑
摘要:最近在用C#做一个项目的时候,Socket发送消息的时候遇到了服务端需要接收C++结构体的二进制数据流,这个时候就需要用C#仿照C++的结构体做出一个结构来,然后将其转换成二进制流进行发送,之后将响应消息的二进制数据流转换成C#结构。1、仿照C++结构体写出C#的结构来 using System.Runtime.InteropServices; [Serializable] // 指示可序列化 [StructLayout(LayoutKind.Sequential, Pack = 1)] // 按1字节对齐 public struct Operator { public ushort id; 阅读全文
posted @ 2010-05-25 10:20 一浩瀚星空一 阅读(494) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示