Giter Site home page Giter Site logo

bonjour's People

Contributors

brutella avatar deepu105 avatar tfheen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bonjour's Issues

In the examples channel is never closed if there are no results

I just noticed that in the examples, if there are no results, the channel is never closed and the goroutine never ends. You can check it out with this script

package main

import (
    "github.com/oleksandr/bonjour"
    "log"
    "os"
    "runtime"
    // "runtime/pprof"
    "time"
)

func main() {
    for {
        resolver, err := bonjour.NewResolver(nil)
        if err != nil {
            log.Println("Failed to initialize resolver:", err.Error())
            os.Exit(1)
        }

        results := make(chan *bonjour.ServiceEntry)

        go func(results chan *bonjour.ServiceEntry, exitCh chan<- bool) {
            for e := range results {
                log.Printf("%s", e.Instance)
                exitCh <- true
                time.Sleep(1e9)
            }
        }(results, resolver.Exit)

        err = resolver.Browse("_foobar._tcp", "local.", results)
        if err != nil {
            log.Println("Failed to browse:", err.Error())
        }
        log.Println("Stack info")
        log.Println(runtime.NumGoroutine())
        time.Sleep(1e9)
        // close(results)
    }
}

Of course it's not a bug, just a documentation issue

Second discovery of a restarted service has no IP

Hey @oleksandr,

first thank you for creating this package :)

I've got a service running somewhere that is perfectly detected once I run my code and if I restart said service it gets detected again, but without an IP:

See this example:
https://gist.github.com/stroborobo/5cc5db74af28706f8e7e

&{{DoomBox\ Uno _mpd._tcp local   } raspberrypi.local. 6600 [] 120 192.168.0.63 fe80::aea1:3a28:a896:1e64}
&{{DoomBox\ Uno _mpd._tcp local   } raspberrypi.local. 6600 [] 4500 <nil> <nil>}

Is that my bad? This is the first time I'm building something around bonjour, so I hope I didn't misunderstand something.

Only receiving one service after a Lookup/Browse

Hello!

I'm not sure if this is an issue with the lib itself or if i'm doing something wrong/misunderstanding.

I am, with this library, registering two services with the same name on two different computers. Then, again with this library, i am doing a resolver.Lookup call with the following code:

resolver, err := bonjour.NewResolver(nil)
if err != nil {
    log.Println("Failed to initialize resolver:", err.Error())
    os.Exit(1)
}

results := make(chan *bonjour.ServiceEntry)

go func(results chan *bonjour.ServiceEntry, exitCh chan<- bool) {
    discover := true
    for discover {
        select {
        case res := <-results:
            log.Printf("Found service: %s, %s", res.Instance, res.Text)
        case <-time.After(time.Second * time.Duration(timeout)):
            log.Print("ServiceDiscovery timed out")
            exitCh <- true
            discover = false
        }
    }
}(results, resolver.Exit)

err = resolver.Lookup("iobox", "_iobox._tcp", "", results)
if err != nil {
    log.Println("Failed to lookup:", err.Error())
}

However i only get one result printed before the timeout(currently set to 30 seconds). I wish to list all devices with an iobox-service. Is there something wrong with my code, or is this not supported?

I'm very new to Go so maybe i'm doing something wrong in this part:

for discover {
  select {
    ...
    discover = false
  }
}

I feel that maybe this isn't the right way to do it. I wish to continue receiving data from the channels until i've timed out.

Does anyone know why it isn't working?

Kind regards,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.