Should I listen on different ports, or the same po

2019-09-06 20:13发布

问题:

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)

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.

So:

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

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

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

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

/Mobile/Orientation2/[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 should just listen to all messages on port 8000, and all Tracker apps, and Mobile apps send to port 8000

vs

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?

I have a related network performance question about the same project at Multicasting big packet contain all info to multiple clients vs individual packets to targeted clients

回答1:

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.