This project is read-only.




I'm trying to setup a custom Bonjour Service.
It seems that a SocketException occurs, when the client and the server is running on the same machine.

Server Code:
    public Network.Bonjour.Service BonjourService { private set; get; }

    private void SetupBonjour()
        BonjourService = new Network.Bonjour.Service();
        BonjourService.Protocol = "_operationManagement._tcp._local.";
        BonjourService.Name = "OperationManagement Server";
        BonjourService.HostName = BonjourService.Addresses[0].DomainName;
Client Code:
        private readonly BonjourServiceResolver _bonjourServiceResolver;

        public MainWindow()

            _bonjourServiceResolver = new BonjourServiceResolver();
            _bonjourServiceResolver.ServiceFound += BonjourServiceResolverOnServiceFound;
            _bonjourServiceResolver.ServiceRemoved += BonjourServiceResolverOnServiceRemoved;

        private void BonjourServiceResolverOnServiceRemoved(IService item)
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => listBox1.Items.Remove(item.Name)));

        private void BonjourServiceResolverOnServiceFound(IService item)
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => listBox1.Items.Add(item.Name)));
Is there anything wrong in my code?


neonp wrote Feb 1, 2013 at 1:45 PM

It's been a long time since I have not tested it. But this issue seems familiar to me. I remember that to try to make this project work, I was either testing publishing to itunes on another computer, or listening to itunes on another computer.

I'll have a look ASAP.

Sisko86 wrote Jun 10, 2013 at 4:48 PM

I think the problem in in class Server method Start.Before binding the socket the following flag has to be set:

server.ExclusiveAddressUse = false;

neonp wrote Dec 29, 2013 at 10:04 AM

Sorry for coming back so late. I've been quite busy these late months. I have checked in the source code and I do have the following code, which should help not throwing the exception you have :server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

Are you testing with the dll or with the source code ? It could be that the dll and source codes are not aligned.