随笔分类 -  Socket网络编程

一个日志记录类
摘要:using System;using System.IO;using System.Net;namespace Utils{public class LogWritter { // 禁止创建同时存在多个对象 private LogWritter(){} private static LogWritter m_logger = null; ... 阅读全文

posted @ 2007-05-17 16:07 BugHunter 阅读(488) 评论(0) 推荐(0)

自定义线程池-c#的简单实现
摘要:自定义线程池-c#的简单实现1.ThreadManager.cs using System;using System.Threading;using System.Collections; namespace CustomThreadPool{ /**//// /// 线程管理器,会开启或唤醒一个线程去执行指定的回调方法 /// public class ThreadM... 阅读全文

posted @ 2007-05-10 15:05 BugHunter 阅读(2112) 评论(0) 推荐(0)

C# 中的委托
摘要:C# 中的委托类似于 C 或 C++ 中的函数指针。使用委托使程序员可以将方法引用封装在委托对象内。然后可以将该委托对象传递给可调用所引用方法的代码,而不必在编译时知道将调用哪个方法。与 C 或 C++ 中的函数指针不同,委托是面向对象、类型安全的,并且是安全的。 委托声明定义一种类型,它用一组特定的参数以及返回类型封装方法。对于静态方法,委托对象封装要调用的方法。对于实例方法,委托对象同时封装一... 阅读全文

posted @ 2007-04-24 17:07 BugHunter 阅读(547) 评论(0) 推荐(0)

IP头和TCP头数据结构(C#版)
摘要:转自[DotNet笔记]IP头和TCP头数据结构(C#版) 1 public struct ip_hdr //IP头 2 { 3 public byte h_lenver; //4位首部长度+4位IP版本号 4 public byte tos; //8位服务类型TOS 5 public ushort tota... 阅读全文

posted @ 2007-04-23 16:41 BugHunter 阅读(581) 评论(0) 推荐(0)

struct和byte[]相互转换(用Marshal类实现)
摘要:转自[DotNet笔记]相当于序列化与反序列化,但是不用借助外部文件1、struct转换为byte[] 1static byte[] StructToBytes(object structObj) 2 { 3 int size = Marshal.SizeOf(structObj); 4 IntPtr buffer = Marsha... 阅读全文

posted @ 2007-04-23 16:16 BugHunter 阅读(1156) 评论(0) 推荐(0)

一个封装的异步Socket客户端
摘要:[转自听香水榭]一个封装的异步Socket客户端 1using System; 2using System.Collections; 3using System.Configuration; 4using System.Net; 5using System.Net.Sockets; 6using System.Text; 7 8namespace Beijing.Traffic... 阅读全文

posted @ 2007-04-18 10:13 BugHunter 阅读(4419) 评论(0) 推荐(0)

导航