Receiving broadcast UDP with Cinder-Asio

Hi all,

I am working on some Master/Slave functionality using the Cinder-Asio block that requires TCP as well as some UDP broadcast. TCP is working well (thanks to help from @ryanbartley), but I am having some issues with UDP.

I seem to be broadcasting UDP messages ok. I can detect them using wiresharkhttps://www.wireshark.org/ and have enabled broadcasting with sessionUdp->getSocket()->set_option(asio::socket_base::broadcast(true));. This has worked for me before to send packets to some hardware. However, even though I can connect a UDP client to the port (on the same machine) it never receives anything. My experience with receiving broadcasts in past is just with OSC libraries and has not required specifying an IP like I need to here. Should I be able to connect to localhost and receive any broadcast messages?

Any help appreciated.
nay.

EDIT - this also did not work with the address “0.0.0.0”, which I take it is what I should be using for the listener. I should probably look at multicasting instead broadcasting for this application but keen to get one of these options working.

Okay, so I managed to get UDP multicasting working by using asio directly. I managed to get these samples running inside Cinder by taking a look at how the OSC block uses standalone asio and switching out the boost dependant code in the samples. Getting it from there into my code was straight forward.

It wasn’t as tricky as I had expected dealing w Asio directly although admittedly this was a very simple use case. Later on I might try doing this for the TCP functionality too but for now I’m just glad it all works!

Cheers,
nay.

Noted. Shouldn’t be tough to add a simple way into multicasting in the next round of updates. If you want to fork and PR, it would be a good way to chat through further API design. I’m not not forums much these days, but I try to be responsive on Github.

Great, might do that when I next get a chance to study further how the block is put together. Thanks!

Hi @nay

I tried creating Multicast application but got an error as cannot input ‘libboost_date_time-vc120-mt-sgd-1_58.lib’ . Searched for same file but couldnt get. Have created project with tinderbox and using boost which comes with cinder. Where can I get that lib?

Hi,

Cinder comes with the full boost source, but to reduce the size of the distribution, it only contains pre-compiled libraries for a few components. You will have to compile date-time yourself. A full description can be found here.

-Paul

1 Like

Thanks @paul.houx - I didn’t know that guide existed!

@Immature - I don’t remember needing this lib for multicasting but I do often use it and think I compiled it with the following command on windows:

bjam toolset=msvc-12.0 address-model=64 link=static runtime-link=static --with-date_time

and on OSX:

./b2 threading=multi toolset=darwin cxxflags="-arch i386 -arch x86_64" target-os=darwin address-model=32_64 link=static runtime-link=static --with-date_time

1 Like

Just a note, if you’re using asio in Cinder, you shouldn’t need boost date_time. You should only need that if you’re trying specifically to not use ASIO_STANDALONE. There’s nothing i believe other than deadline_timer that uses boost in asio anymore (Even that was replaced by basic_waitable_timer). Most likely why it was trying to find ‘libboost_date_time-vc120-mt-sgd-1_58.lib’ is because there was likely an #include "asio..." somewhere that wasn’t preceded by a #define ASIO_STANDALONE. If you can find that the error should go away.

2 Likes

@ryanbartley

Yes I am using asio in cinder and have got that error. I tried compiling with the syntax provided by @nay but it didnt work. Thank you @paul.houx for that tutorial.

If you could, search in your project and throughout the block for any includes like #include "asio/..." lines and add #define ASIO_STANDALONE above it.

Hello
Does Cinder-Asio block work on ubuntu 16 ?

Thanks