It has been a very long time since I have tried using Juce… so please forgive me if I missed something simple.
I need to send a broadcast packet for a client/server application. I have written standard C code using WinSock2 and it works fine. I’m now trying to port this into a JUCE application and I am running into an issue.
Specifically, I need to do two things that I don’t see a way to do:
I need to determine the local IP address, so I can build the proper sub-net address for the broadcast packet. In my C code I do this with gethostbyname(). This appears to not be available to DatagramSocket().
I need to call sendto() to a DatagramSocket (unconnected) and I need to specify the broadcast server address with a sub-net mask of “255.255.255.0” (otherwise the router will drop the packet). I have looked through juce_Socket.cpp and I cannot see a way to do this.
I see that DatagramSocket() can have a parameter “allowBroadcast” set to true, but I don’t see that this does anything other than call setSockOpt( …SO_BROADCAST… ), which for Windows at least isn’t really needed.
Since for both OSX and Windows (haven’t looked at iOS or Android yet), most of the socket calls are already cross platform, could I just get the private handle out of DatagramSocket() and use my already working C code?
Thanks for your help,
David A. Hoatson