using UDP efficiently.
When using udp to send messages,I have a habit to use a new udp port each time I need to send something, very easy and quick but can result in lots of ports being used. Or I use just one port; and with (sprintf) or (prepend), give the desired message a unqiue ID so to speak, then the other side I use (route) or (zl compare) to decode the message out. So I can then have many messages sent through just one udp port.
I am wondering which is more efficient? To have lots of ports in use or to have lots of (sprintf)’s and (route)’s working on just one port with longer messages? Can one port become clogged relative to multiple ports? Or maybe too many ports be used at once?
Does anyone have any info they could share?
thanks : )
I’d use one port (or only a few) and a combination of OSC-route and OSC-unroute.js, from CNMAT.
I would *not* use sprintf heavily if I was concerned about efficiency.
ye osc style formatting/parsing is the way to go if you want to use only 1 udp port
cnmat now provides the awesome odot library for osc related operations.
wow have i got some work to do if i want to remove all my sprintf’s i use them allot for designing messages.
I shall check out the OSC route and unroute as you both suggest.
If i switch over to these osc objects i shall take a note of my CPU usage before and after and post results. might be a while though. I think i must have 100′s udp ports in use. : /
At least i feel i am not doing something drastically wrong using lots of ports. I was kinda worried for some reason.
thanks again : )
… OR you could simply do [s ---toudp] with a matching receive object for that ONE udp object.
Am I missing something? That’s what you were asking originally, right? I think that’s the best way to handle it. I do [s ---tolemur] all the time, it keeps things really clean.
i see what you mean, use lots of sends around a patch to one udp instead of lots of the same udp.
kind of. however I am using lots of udps with different ports. i have hundreds of ports open all over the place. and i wanted to know if that was good or bad
i have been told to reduce the port count down and use oscroute and unroute to help me do this. I could use sends like you suggest too,
i wonder if 100 sends to one udp object uses more or less resources than 100 udp objects with the same ip and port?
Having hundreds of ports open sounds messy and unnecessary – generally have only ever seen a few used at most.
Also check out the odot series of objects from CNMAT – o.route is better then OSCroute . . .