来自同一台PC的多个客户端套接字 [英] multiple client sockets from same pc

查看:131
本文介绍了来自同一台PC的多个客户端套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用c#构建了一个服务器应用程序。因此,我需要测试具有许多客户端,相同端口的服务器行为。

I built a server application with c#. Thus, I need to test server bahavior with many clients, same port.

我构建了一个与此服务器通信的客户端应用程序。

I built a client application that communicates with this server.

两个应用程序都使用异步套接字。

Both applications use asynch sockets.

我修改了客户端应用程序以创建10-100个套接字连接到该服务器。

I modified the client application to create 10-100 sockets and connect to that server.

问题是:

- 在创建这些套接字并将它们连接到服务器时,只接受了30%。

- On creating these sockets and connecting them to server, only 30% were accepted.

- 客户端一个接一个地丢失连接,直到只有一个客户端保持连接状态。

- Connection is lost with clients one by one until only one client remains connected.

问题是:

- 服务器是否可以沟通客户端来自相同的IP地址/端口?

- Can a server communicate with clients originating from same IP address/port?

- 同一进程(同一应用程序)上的多个客户端是否可以与同一IP /端口上的服务器通信?我是否需要为每个客户提供单独的流程?

- Can multiple clients on same process (same application) communicate with a server on same IP/port? Do I need a separate process for each client?

- 如果所有(服务器+客户端)都位于同一台PC(用于测试!),则此方案是否适用?

- If it happens that all (server + clients) reside in same PC (for testing!), can this scenario be applicable?

感谢您的帮助。

推荐答案


 

问题是:

- 服务器是否可以与来自同一IP地址/端口的客户端通信?

- Can a server communicate with clients originating from same IP address/port?

是。

- 同一进程(同一应用程序)上的多个客户端可以与同一IP上的服务器通信吗?

- Can multiple clients on same process (same application) communicate with a server on same IP?

是。

我是否需要为每个客户提供单独的流程?

Do I need a separate process for each client?

是。但是,单独的线程,不一定是一个单独的过程。

- 如果所有(服务器+客户端)都位于同一台PC(用于测试!),这种情况是否适用?

- If it happens that all (server + clients) reside in same PC (for testing!), can this scenario be applicable?

是。

很久以前我试图探索两个客户端连接到的可能性相同的端口 - 他们将有两个插座但共享端口。我的回忆是,实际上它是没有意义的(在实际术语中),可能通过设置一个Socket参数来实现,它可能是Socket类的不可能,通过使用Winsock可能是可能的,但最终的设计将是在运行时不稳定(不可预测的流流),并且我没有与之交谈的任何人都有这样做的直接经验。

Long time ago I tried to explore a possibility that two clients are attached to the same port--they would have two sockets but share the port. My recollection is that realistically it is meaningless (in practial terms), that it might be possible to implement by setting one Socket parameter, that it is perhaps impossilble with Socket class, that it could be possilbe by using Winsock but the resulting design will be unstable at runtime (unprectable stream flow), and that nobody I talked to had any direct experience of doing so.


这篇关于来自同一台PC的多个客户端套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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