Example #1
0
/*
	Establishes a connection with tegu. This blocks until a connection is established
	and tries every few seconds until successful.
*/
func connect2tegu(smgr *connman.Cmgr, host_port *string, data_chan chan *connman.Sess_data) {

	burble := 0 // limit our complaining to once a minute or so

	for {
		err := smgr.Connect(*host_port, "c0", data_chan)
		if err == nil {
			sheep.Baa(1, "connection with tegu established: %s", *host_port)
			return
		}

		if burble <= 0 {
			sheep.Baa(0, "unable to establish a connection with tegu: %s: %s", *host_port, err)
			burble = 12
		}

		time.Sleep(5 * time.Duration(time.Second))
		burble--
	}
}