本文介绍了我应该在其他端口还是在同一端口上侦听?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个C ++应用程序MyMasterApp(Windows和Mac),它正在侦听来自不同计算机和应用程序的大量信息. (通过UDP的OSC)

I'm writing a C++ application MyMasterApp (windows & mac) which is listening to a bunch of information coming from different computers and applications. (OSC via UDP)

即MyMasterApp正在侦听来自多个Tracker应用程序的跟踪数据(这些跟踪器应用程序可能运行或可能不在同一台计算机上,但在同一有线网络上运行).它还正在侦听来自其他许多应用程序的定向数据(在同一wifi上的移动设备上运行).所有应用程序均以30Hz发送.

I.e.MyMasterApp is listening for Tracking data coming from a number of Tracker applications (which may or may not be running on the same computer, but on the same wired network).It's also listening to orientation data coming from a number of other applications (running on mobile devices, on the same wifi).All apps are sending at 30Hz.

所以:

/Tracker/Position1/[f] [f] [f]

/Tracker/Position1/[f] [f] [f]

/Tracker/Position2/[f] [f] [f]

/Tracker/Position2/[f] [f] [f]

/Tracker/Position3/[f] [f] [f]

/Tracker/Position3/[f] [f] [f]

/移动/方向1/[f] [f] [f] [f]

/Mobile/Orientation1/[f] [f] [f] [f]

/移动/方向2/[f] [f] [f] [f]

/Mobile/Orientation2/[f] [f] [f] [f]

/Mobile/Orientation3/[f] [f] [f] [f]

/Mobile/Orientation3/[f] [f] [f] [f]

我想知道是否存在以下差异(网络性能,冲突等)

I'm wondering whether there is any difference (in network performance, collisions etc) if:

MyMasterApp应该只侦听端口8000上的所有消息,并将所有Tracker应用程序和移动应用程序发送到端口8000

MyMasterApp should just listen to all messages on port 8000, and all Tracker apps, and Mobile apps send to port 8000

vs

MyMaster侦听端口8000上的Tracker消息,以及端口9000上的Mobile消息.

MyMaster listens to to Tracker messages on port 8000, and Mobile messages on port 9000.

两者似乎都可以正常工作,我只是想知道两者之间在性能上是否有优势,甚至关于使用哪一个的经验法则.有没有一个理论上的或记录的实践上的优势?还是差异可以忽略不计?

Both seem to work fine, I'm just wondering if there is any performance advantage of one over the other, or even a rule of thumb as to which one to use. re there any theoretical, or recorded practical advantages of one over the other? Or are the differences just negligible?

我在

推荐答案

唯一的真正区别在于代码:使用不同的套接字更容易解码不同的协议,还是开销可以忽略不计.

The only real difference is in your code: whether it is easier to decode different protocols by using different sockets or whether that overhead is negligible.

这篇关于我应该在其他端口还是在同一端口上侦听?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 11:56