[英]Run multiple services which control port
I have a windows service which listens for TCP messages, responses to them and then saves information to a database. 我有一个Windows服务,该服务侦听TCP消息,对其进行响应,然后将信息保存到数据库中。 Overall the CPU and memory usage is relatively small.
总体而言,CPU和内存使用量相对较小。
I would like to run multiple of these on a single machine however the problem is that the only way I know which service is by the destination IP. 我想在一台机器上运行多个服务,但是问题是,我知道哪种服务的唯一途径是目标IP。 Thus is it possible for multiple to run on a single machine?
因此,有可能在单个计算机上运行多个文件吗?
Update: I need them to all run on the same port. 更新:我需要它们全部在同一端口上运行。 Thus service1 and service2 both listen on port X. A message intended for service1 must not go to service2.
这样,service1和service2都在端口X上侦听。发给service1的消息一定不能进入service2。 The messages themselves are indistinguishable.
消息本身是无法区分的。 The only way the message knows it is going to service1 is the destination ip.
消息知道到达service1的唯一方法是目标ip。
I guess port was originally designed to be some type of “service ID”, if this is completely inappropriate, you should consider additional logic inside your service for load balancing. 我想端口最初设计为某种“服务ID”,如果这完全不合适,则应考虑服务内部的其他逻辑以实现负载平衡。 Or something else...
或者是其他东西...
Can two applications listen to the same port? 两个应用程序可以侦听同一端口吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.