如何为C#中的消息交换服务多个Tcp客户端创建线程 [英] How Do I Create Threads For Serving Multiple Tcp Clients For Message Exchange In C#

查看:64
本文介绍了如何为C#中的消息交换服务多个Tcp客户端创建线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用客户端服务器TCP应用程序,在这两者之间交换消息但功能相反,即服务器发送连接请求并且客户端侦听端口。现在在服务器表单上,我有一个datagridview,其中存储了客户端主机名列表,并使用我想要连接到所有客户端的线程。

我正在使用

Hi,

I am working on a client server TCP application where messages are exchanged between the two but the functionality is reversed, i.e. the server sends the connect request and the client listens on a port. Now on the server form, i have a datagridview where a list of client hostnames are stored and using a thread i want to connect to all the clients.
I am using

Thread[] array1 = new Thread[4];
                    for (int j = 0; j < 4; j++)
                    {
                        // Start the thread with a ParameterizedThreadStart.
                        ParameterizedThreadStart start = new ParameterizedThreadStart(Start);
                        array[j] = new Thread(start);
                        array[j].Start(j);
                    }





任何人都可以帮我解决这个问题,让我知道如果iam做得好或有一些链接或一些代码片段?



Can anyone help me out with this and let me know if iam doing fine or with some links or some code snippets ?

推荐答案

这篇关于如何为C#中的消息交换服务多个Tcp客户端创建线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆