02-14-07 12:18 AM
"Henrik Goldman" <henrik_goldman@mail.tele.dk> wrote in message
news:45d1d063$0$908$edfadb0f@dread12.news.tele.dk...
>
> In an ideal world I'd certainly like to do your proposal. However
> non-technical things forces me not to use this as an option. One strong
> requirement is that people must say it's easy to use and not say it's too
> hard to install two services instead of one. [...]
Couldn't you build the functionality into the existing daemon? Probably the
simplest way would be to fork (twice, probably) if you succeed in binding
the UDP socket, and have the (grand)child become the "server location
service". The obvious problem with this approach is discovery stops working
forever if the service dies.
Alternatively, maybe something like the following would work. Periodically
create a UDP socket and try to bind it to the discovery port. If bind()
fails, send a message to the discovery port saying "I am a server listening
on TCP port X." If it succeeds, in addition to responding to discovery
messages, handle the "I am a server" messages: add the server to a list with
a timeout that is greater than the period between bind attempts. When you
receive a discovery message, purge expired entries from the list then send
the list (plus your own TCP port). This approach is not perfect - for
instance, it creates a "hiccup" in server discovery if the server with the
UDP socket exits or dies. There are probably issues I didn't think of; if
so, perhaps someone else will point them out.
Alex
[ Post a follow-up to this message ]
|