首页 Soft PlugIn RAN乱 Dev开发 Info资料 English WAP 留言 登陆 注册
-
Posted by Yippee | 评论(0) | 引用(0) | 阅读169次
20080715 c# socket delegate

20080715 c# socket delegate
http://www.shengfang.org


static int listenport = 8000;
        Socket clientsocket;
        TcpListener listener;
        Thread clientservice=null;
        private void StartListening()
        {
            listener = new TcpListener(IPAddress.Parse("127.0.0.1"), listenport);
            listener.Start();

            while (true)
            {
                try
                {
                    Socket s = listener.AcceptSocket();
                    clientsocket = s;
                    clientservice = new Thread(new ThreadStart(ServiceClient));
                    clientservice.Start();

                    //MessageBox.Show(clientservice.ToString());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }
        private void ServiceClient()
        {
            Socket client = clientsocket;

            bool keepalive = true;
            System.IO.BinaryReader reader = null;
            reader = new System.IO.BinaryReader(new NetworkStream(client));
          
            while (keepalive)
            {
                //Byte[] buffer = new Byte[1024];
                //client.Receive(buffer);
               
                log("rec:" + BitConverter.ToString(dp.GetBytes()));
                log("rec:" + dp.strData);
            }
        }
        delegate int SetTextCallback(string text);
        public  int log(string s)
        {
            if (this.txt.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(log);
                this.Invoke(d, new object[] { s });
            }
            else
            {
                txt.Text = DateTime.Now.ToString() + s + "\r\n" + txt.Text;
            }

           
            return 0;
        }
        Thread threadListen=null;

http://www.cnblogs.com/imissherso/archive/2007/01/28/632480.html
线程间操作无效: 从不是创建控件“...”的线程访问它。

http://zhidao.baidu.com/question/56199307.html
c#线程问题:线程间操作无效:从不是创建控件picMonster1的线程访问它InvalidOperationException异常

关于多线程处理--线程切换
http://blog.csdn.net/taoxming/archive/2006/10/11/1330530.aspx

http://hi.baidu.com/84547054/blog/item/dc0077261deeba128a82a1a7.html
Visual C#托管Socket的实现方法(转载)

http://hi.baidu.com/jobsmeng/blog/item/da52b9d9401f842910df9b33.html
C#多线程编程---一个简单的聊天程序(Server)

http://1985wanggang.blog.163.com/blog/static/7763833200781424410226/
unix-C#中间件的通信

http://blog.cnbb.com.cn/outcast/archive/2008/03/02/71524.html
C#中TcpListener类的使用(AcceptTcpClient()方法-MSDN)

http://barton131420.cnblogs.com/archive/2005/12/07/292176.html
细节决定成败:映射枚举

XmlNode node = objTmplt.Attributes["name"];
if (node != null)
styleName = node.Value;
or:
XmlNode node = objTmplt.Attributes["name"];
if (node != null && !string.IsNullOrEmpty(node.Value))
styleName = node.Value

http://www.codeproject.com/KB/cs/xmladapter.aspx
Quick Xml Read and Write Adapters for C#

也谈用反射实现Enum→String映射:一种重视性能的方法
http://www.cnblogs.com/smalldust/archive/2006/04/25/384657.html

http://www.codeproject.com/KB/dotnet/unhandledexceptions.aspx


字体:

Permanant URI永久地址 http://www.shengfang.org/blog/p/20080715csocketdelegate.php
Trackback URI引用地址 http://www.shengfang.org/blog/tb.php?tb_id=1236060839

2009年3月3日14:13星期二  [Dev开发] 追踪此文的RSS
提示:
此文还没有评论。

称呼:    登陆   注册
   不注册,但记住我的信息
邮件:
(非必须)
评论: [UBB代码帮助]
粗体 斜体 下划线 链接 水平线 引用



验证码: 请输入你看见的数字
关闭UBB      提交时自动将内容复制到剪贴板

公告
Fire and Motion!

统计信息
[Yippee]||[统计]||日志:1887
在线: 25||用户: 2579 [列表]
今日:653||到访:2931371
Rss:||评论:1609

最新日志

最新评论

友情链接

日历
2008 - 08
     12
3456789
10111213141516
17181920212223
24252627282930
31      

最新引用

搜索

归档

杂项
Get RSS Feed (Version 2.0)
Get Atom Feed (Version 0.3)
编码:  UTF-8