This project is read-only.

How often to call publish ?

Oct 13, 2009 at 3:52 PM

From my experimentation of this library, in order to be able to detect a "server/publisher" it is expected for the "server/publisher" to continuously call the publish() method. If the client looking for the service is instantiated after the initial publish() call of the server it seems like the client is never able to find the server. I have tested this both with using the Sample client app and the Bonjour plugin provided by Apple for IE.

Is this behavior expected ? I am not fully aware of the architecture used for Bonjour and wasn't sure if this library was suppose to do automatic broadcasts or not. (I will admit that I haven't looked through the source code to see what's going on :-)  )

Sample Code (works only if the client is already running):

_bonjourService = new Network.Bonjour.Service();
_bonjourService.AddAddress(Network.ZeroConf.ResolverHelper.GetEndPoint());
_bonjourService.Protocol = "_http._tcp.local.";
_bonjourService.Name = "Sample Service";
_bonjourService.HostName = _bonjourService.Addresses[0].DomainName;                                  
_bonjourService.Publish();

 

Sample Code( works if client is brought up within 100 seconds of the server)

_bonjourService = new Network.Bonjour.Service();
_bonjourService.AddAddress(Network.ZeroConf.ResolverHelper.GetEndPoint());
_bonjourService.Protocol = "_http._tcp.local.";
_bonjourService.Name = "Sample Service";
_bonjourService.HostName = _bonjourService.Addresses[0].DomainName;                                  
         
for (int i = 0; i < 10; i++)
{
  _bonjourService.Publish();
  Thread.Sleep(10000);
}

Oct 13, 2009 at 3:59 PM

Hi,

 

Actually, you should call the publish method only once. I know that I need to handle the expiration of the service (120s by default). If you start you client within this interval, it should work without calling publish again.

 

This is a "known issue". Just need to find to time to implement it.