Help us shape the future of Go! Take the 2026 Go Developer Survey

disco

package module
v0.0.0-...-b97a54f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2017 License: MIT Imports: 5 Imported by: 1

README

Build Status

disco

Simple library to send and receive multicast messages

Documentation

Index

Constants

View Source
const (
	// TypeAnnounce should be used to announce presence
	TypeAnnounce = "announce"

	// TypeQuery should be used to ask whether a service with a
	// specific name is present
	TypeQuery = "query"

	// Response should be used to respond to TypeQuery messages
	TypeResponse = "response"

	// Report should be used to ask everyone on the network to
	// report that they are alive
	TypeReport = "report"
)

Constants that denote the different types of service messages

Variables

View Source
var MaxDatagramSize = 8192

MaxDatagramSize sets the maximum amount of bytes to be read

Functions

func Announce

func Announce(mAddr, srcAddr, name string) error

Announce sends out an announcement on the mAddr that other clients can listen to. ListenFor can interpret these srvc messages

func Broadcast

func Broadcast(addr, message string) error

Broadcast sends a message to the multicast address via UDP. The address should be in an "ipaddr:port" fashion

func ListenFor

func ListenFor(addr string, names ...string) (<-chan Service, error)

ListenFor returns a channel that sends a message if any of the names that was requested has announced itself on the multicast addr. Once announced, the whole message will be returned and then removed from the watchlist

func Respond

func Respond(mAddr, srcAddr, name string) error

Respond sends a response type broadcast

func Subscribe

func Subscribe(addr string) (<-chan MulticastMsg, error)

Subscribe starts listening to a multicast address via UDP. The address should be in an "ipaddr:port" fashion.

Types

type MulticastMsg

type MulticastMsg struct {
	Message string
	Src     string
	Err     error
}

MulticastMsg is used to communicate a message that was received on a multicast channel. Contains information about the sender as well, or an error if any arose.

type Service

type Service struct {
	Name string
	Addr string
}

Service represence a name-ipaddress:port combination

func Query

func Query(mAddr, srcAddr, name string, timeout time.Duration) (Service, error)

Query sends out a query type broadcast and waits up until timeout for a response.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL