多个端口侦听单个插槽 [英] Multiple port listening on single socket

查看:73
本文介绍了多个端口侦听单个插槽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,



我有一个项目,我必须在VB.net中收听超过100个端口。

我有点混淆是否通过多线程在单个套接字上监听这些端口或者在单个套接字上监听这些端口。



此外,数据出现的时间以秒为单位。而且我不想错过任何数据,因为它非常关键。



请为此建议一些解决方案。

Dear Sir,

I have a project in which I have to listen more than 100 ports in VB.net.
I m little bit confused whether to listen these port on single socket through multithreading or to listen these port on individual socket.

Also data occurance is in seconds. And I dont want to miss any data as it is very critical.

Please suggest some solution for this.

推荐答案

100个帖子?好的,这很奇怪。我从来没有听说过任何同时收听100个端口的应用程序,也没有听说过任何合理的情况。



你可能想要拼写完全了解这100个端口的情况。为什么你认为你必须使用100个端口?一次有多少数据来自远程设备?



一次只能有一个东西可以在一个端口上监听,所以这并不是很多感觉。
100 posts?? OK, that''s weird. I''ve never heard of any application that listens to 100 ports at the same time, nor any situation where it''s justified.

You might want to spell out EXACTLY what is going on with these 100 ports. Why do you think you have to use 100 ports? How much data is coming from a remote device at one time?

Only one thing can listen on a port at a time, so this doesn''t make a lot of sense.


Dave'是的 - 我们需要更多信息......必须有更好的方法。如何监听单个端口并接受多个(100个或更多)连接?这似乎是找我的正确方法。但简而言之 - 你不能用一个插座听100个端口。你需要100个插座。如果这就是你真正想做的事情。



为什么不查看我的文章:可重用的多线程TCP客户端和服务器类以及VB.NET中的示例项目



我想这个,你可能会做你需要的。



- Pete
Dave''s right - we need more information... There has to be a better way. How about listening on a single port and accepting multiple (100 or more) connections? That seems like the right way to go to me. But in short - you can''t listen to 100 ports with a single socket. You''ll need 100 sockets. If that''s what you really want to do.

Why not check out my article: Reusable multithreaded TCP client and server classes with example project in VB.NET

I think with this, you will likely be able to do what you need.

- Pete


这篇关于多个端口侦听单个插槽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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