Hi, I’m just starting some work on the StreamRadio app, mostly for fun. I was facing a problem with a particular radio station, that sometimes would play flawlessly and others would not.
After digging in the code for a while and enabling debug messages (I don’t really know C++), I’ve found the domain name is resolving to two different IP’s. Both respond to ping, but only one of them is listening on port 7200, which the Icecast server uses for streaming.
Haiku only seems to use the first address received. So, if for some reason the DNS reply had the “wrong” server in first place, the radio wouldn’t play. Closing the app apparently deletes the DNS cache, so it’s a matter of trying until the DNS response points to the “good” server.
I’ve tried with VLC and Windows Media Player, both on Windows, and they somehow know if they get a “connection refused” with the first IP, they have to try with next one. I’m not sure if that logic it’s embedded in the apps or if the network implementation on Windows checks for connection on the specified port.
My question is, how should I approach this? I’ve seen the RequestCompleted method in the UrlProtocolListener class, I know I can override that method and check for success and do something about it, but if I start a new request it’s probably going to resolve to the same IP address, since it’s cached.
Is there a way to check for connection on a specified port and force using the next address using the network kit classes?
Thanks in advance!
Javier
EDIT: by the way, the stream is http://sa.mp3.icecast.magma.edge-access.net:7200/sc_rad30
If you try enough times with StreamRadio, closing and opening the app, it will fail eventually. Can’t remember if Clementine (for example) is having the same problem, but I guess being a ported app it might use a different resolver mechanism