[Live-devel] Problem with ourSourceAddressForMulticast()
David Betrand
bidibulle at operamail.com
Thu Feb 1 12:21:52 PST 2007
Ross,
I think you misunderstood me. My replies are inline.
> If that happens, then you have a more serious problem: you've stopped
> multicast from working! For multicast to work, your
> "ReceivingInterfaceAddr" - if not INADDR_ANY - must be set to the
> interface on which you have a route for 224.*.
I'm not doing multicast at all, only unicast. But, each time a Groupsock is created a call of ourSourceAddressForMulticast is performed and thus some multicast sending/receiving also. And I really guess that 99% of computers of our beautiful planet will fail to read the multicast packet sent to guess our source address IF you set ReceivingInterfaceAddr and SendingInterfaceAddr to your ethernet IP address (example : 192.168.0.1).
Can you try to slightly modify, for example, testOnDemandRTSPServer.cpp to add those two line in your main() :
SendingInterfaceAddr = our_inet_addr("a.b.c.d");
ReceivingInterfaceAddr = our_inet_addr("a.b.c.d");
where "a.b.c.d" is a unicast IP address defined on your server
and add also
#include "GroupsockHelper.hh"
You will see (I hope ;-)) that your app wait for 5 seconds after an answer and then swith to the secondary method to get its source IP.
> A regular Linux configuration *does* have multicast - at least, a
> route for 224.*.
I would say : there is a route to a default gateway which probably as one.
> > - Getting a valid IP address from gethostname() followed by
> > gethostbyname() doesn't work on most unix and linux systems as it
> > only returns the first entry in /etc/hosts file : 127.0.0.1. And
> > this IP address is rejected by badAddress().
>
> That's not supposed to happen. The code is supposed to check through
> *all* of the addresses returned by "gethostbyname()", and use the
> first address that is not bad (and 127.0.0.1 is considered 'bad').
The code is correct. The problem is that a Linux machine seems to answer with only the FIRST address it finds for the hostname, most of the time 127.0.0.1. I observed this on my Linux RedHat Enterprise 4 server, and crosscheked on some forums on internet.
> > So, is it reasonnable to set a global static variable for the source address.
>
> No. If the code cannot find the machine's source address - using
> either of the two methods (multicast loopback or
> gethostname()/gethostbyname()) - then you probably have more serious
> problems that would prevent other parts of the code from working
> properly. Allowing the programmer to 'paper over the problem' by
> specifying an address 'by hand' would likely cause more harm than
> good.
I partly agree with you. However, in my case, what I have to do to make my app working is to call ourAddressForMulticast() at the very beginning of my main() (before setting ReceivingInterfaceAddr and SendingInterfaceAddr). Not really "clean" either ...
I'm just trying to show that, in some cases, the library's user that I am has to strugle for days and prefer to share his experience with all of you. But as I told you, I can now avoid my problem, so forget it if you prefer.
Cheers,
David
--
_______________________________________________
Search for products and services at:
http://search.mail.com
Powered by Outblaze
More information about the live-devel
mailing list