摘要: http://www.cnblogs.com/peterzb/archive/2009/05/29/1491605.html 阅读全文
posted @ 2013-02-10 22:17 louiskoo 阅读(146) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Net;using System.Net.Sockets;using System.Text;public class SynchronousSocketClient { public static void StartClient() { // Data buffer for incoming data. byte[] bytes = new byte[1024]; // Connect to a remote device. try { // Establ... 阅读全文
posted @ 2013-02-10 21:09 louiskoo 阅读(203) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Net;using System.Net.Sockets;using System.Text;public class SynchronousSocketListener { // Incoming data from the client. public static string data = null; public static void StartListening() { // Data buffer for incoming data. byte[] bytes = new ... 阅读全文
posted @ 2013-02-10 21:08 louiskoo 阅读(196) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Net;using System.Net.Sockets;using System.Text;using System.Threading;// State object for reading client data asynchronouslypublic class StateObject{ // Client socket. public Socket workSocket = null; // Size of receive buffer. public const int BufferSize = 102... 阅读全文
posted @ 2013-02-10 21:02 louiskoo 阅读(299) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Net;using System.Net.Sockets;using System.Threading;using System.Text;// State object for receiving data from remote device.public class StateObject{ // Client socket. public Socket workSocket = null; // Size of receive buffer. public const int BufferSize = 256;... 阅读全文
posted @ 2013-02-10 21:01 louiskoo 阅读(250) 评论(0) 推荐(0) 编辑
摘要: AsyncServer: Bind - Listen - BeginAccept - EndAccept - BeginReceive - EndReceive - BeginSend - EndSend - Shutdown - CloseAcceptCallbackReadCallbackSendCallbackAsyncClient: BeginConnect - EndConnect -BeginSend - EndSend - BeginReceive - EndReceive- Shutdown - Close ConnectCallbackSendCallback Receive 阅读全文
posted @ 2013-02-10 20:57 louiskoo 阅读(222) 评论(0) 推荐(0) 编辑
摘要: BackgroundWorker connectWork = new BackgroundWorker(); public FormClient(){ connectWork.DoWork += new DoWorkEventHandler(connectWork_DoWork); connectWork.RunWorkerCompleted += new RunWorkerCompletedEventHandler(connectWork_RunWorkerCompleted);} /// <summary> /// 异步方式与服务器进行连接 ... 阅读全文
posted @ 2013-02-10 16:59 louiskoo 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 执行顺序不一样 private static int newTask(int mms) { //C } private delegate int NewTaskDelegate(int mms); static void Main(string[] args) { //A NewTaskDelegate newTst = newTask; IAsyncResult asyncResult = newT... 阅读全文
posted @ 2013-02-10 01:19 louiskoo 阅读(181) 评论(0) 推荐(0) 编辑
摘要: NetworkStream networkStream = client.GetStream(); BinaryReader br = new BinaryReader(networkStream); BinaryWriter bw = new BinaryWriter(networkStream); 阅读全文
posted @ 2013-02-10 01:03 louiskoo 阅读(184) 评论(0) 推荐(0) 编辑
摘要: PerformClick生成按钮的Click事件。 阅读全文
posted @ 2013-02-10 01:01 louiskoo 阅读(400) 评论(0) 推荐(0) 编辑