- Notifications
You must be signed in to change notification settings - Fork27
koron/go-ssdp
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Based onhttps://tools.ietf.org/html/draft-cai-ssdp-v1-03.
There are tiny snippets for example. See also examples/ directory for workingexamples.
import"github.com/koron/go-ssdp"ad,err:=ssdp.Advertise("my:device",// send as "ST""unique:id",// send as "USN""http://192.168.0.1:57086/foo.xml",// send as "LOCATION""go-ssdp sample",// send as "SERVER"1800)// send as "maxAge" in "CACHE-CONTROL"iferr!=nil {panic(err)}// run Advertiser infinitely.quit:=make(chanbool)<-quit
import"time"aliveTick:=time.Tick(300*time.Second)for {select {case<-aliveTick:ad.Alive() }}
import ("os""os/signal")// to detect CTRL-C is pressed.quit:=make(chan os.Signal,1)signal.Notify(quit,os.Interrupt)loop:for {select {case<-aliveTick:ad.Alive()case<-quit:break loop }}// send/multicast "byebye" message.ad.Bye()// teminate Advertiser.ad.Close()
go-ssdp will send multicast messages to all IPv4 interfaces as default.When you want to limitate interfaces, see below snippet.
import ("github.com/koron/go-ssdp""net")en0,err:=net.InterfaceByName("en0")iferr!=nil {panic(err)}ssdp.Interfaces= []net.Interface{*en0}
go-ssdp will send multicast message only "en0" after this.
About
SSDP library
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.