I know this has been an issue for others too, but was wondering if anyone found a solution.
I’d like to broadcast OSC Messages to my local subnet, and usually with UDP this happens by sending the message to FF.FF.FF.FF or keeping the subnet mask and setting all the bits (e.g. 192.168.0.FF if subnet is 192.168.0 and mask is FF.FF.FF.0). This also works when sending with OSC - except when using oscPack, and unfortunately ofxOsc is built on oscPack so doesn’t work. Does anyone know what the best solution to this is? (even if it is a hack for now).
Hey Arturo, unfortunately couldn’t get it to work (1st param I think is socket_ instead of socket for it to compile btw.). I’m trying on iPhone so that may have something to do with it. ofxOsc works perfectly on iPhone - (which I was a bit surprised to be honest to be able to use the normal libOsc.a! Do you not need iphone specific libs?) but broadcasting doesn’t. Maybe its not supported on iPhone?
i was googling and it seems it should be supported. anyway the broadcast address i wrote was wrong, it should be your network address xor network mask.
so if you have 192.168.0.1 as ip address and 255.255.255.0 as network mask the broadcast address should be 192.168.0.255
in mac ifconfig should tell you the broadcast address
I tried several values for the broadcast address, but as memo said, it has to be built from the IP and the subnet mask. Did you manage to get this information (by code) ?
One more thing worth to mention is that with the iPhone simulator, the app receives its own broadcasted message, but on iPod Touch it does not.
i just downloaded the source from the svn, and added arturo’s code with memo’s fixes.
on linux64 you also have to manually add “OSC_HOST_LITTLE_ENDIAN” to the #define section in the build settings.
with that in place i was able to use my broadcast address, which i got using ifconfig (192.168.8.255).
to get this address programmatically, there is probably something smart you could do with API-ish things against linux… but in the worst case you could always parse the result of calling ifconfig
Yeah, super helpful for what I’m doing at the moment.
I’m talking to the oscpack author about adding these two options (broadcast, address reuse) into oscpack as options that can be set. Hopefully they’ll be incorporated.
I can get the broadcasting/multicasting to work using the changes above. But as soon as more than one client application on the same local host tries to “listen in”, it gets rejected with a “unable to bind udp socket” error.
Kyle, Memo, what’s the current status of this in 007? Did those options get incorporated into oscpack, and are they in ofxOsc in 007? It seems at least address reuse is not implemented, that doesn’t work with stock ofxOsc for me. Is this endianness-fix for 64bit still necessary in 007?
It doesn’t appear this got implemented. Can someone post a compiled lib (personally I’m looking for ofxiPhone compliation)? Trying to send to 255.255.255.255 using an iOS device isn’t working.
Thanks Arturo, but I couldn’t figure out how to recompile it. I changed the things it said in the makefile for OSX and ran ‘make’ and ‘make lib’ but it doesn’t create the .a. I don’t use make enough to know what I’m doing heh.
edit: I wasn’t able to compile it as a seperate lib .a, but I was able to compile it as part of the project I’m using instead by including the source. So, that works for now. It still doesn’t work with 255.255.255.255 though (anyone have that working?), but it does work with 192.168.1.255 which it didn’t before.
yes actually 255.255.255.255 is not the broadcast address. you can get the broadcast address by doing an binary or of the ip address and the negated subnet mask. so if your address is 192.168.1.xxx and your subnet mask 255.255.255.0:
192.168.1.xxx | 0.0.0.255 = 192.168.1.255
255.255.255.255 is the broadcast address for the local network and though it should work it doesn’t for some systems like the iphone
Ah ok thanks. I guess the problem is, what if you want devices to connect to each other without having to manually input an IP. Is there a way for them to auto discover the broadcast IP? Does oscpack have a getIP function? I couldn’t find it.
there’s also this thing called libmapper, which adds another layer to OSC, so to say, to add things like autodiscover, mapping of messages, etc.
I think it could be worthwhile to get this over to oF, there’s even a guy who began ofxlibmapper, but i don’t have the time and skills for that. I want(ed) to build something like osculator, just crossplatform and opensource, with it. https://github.com/radarsat1/libmapper