func (c *Conn) Close() error {
	select {
	case <-c.closed:
		return nil
	default:
	}
	if err := c.socket.Close(); err != nil {
		return err
	}
	<-c.closed
	return nil
}
Close closes the mDNS Conn
package mdns
import (
	"context"
	"math/big"
	"net"
	"sync"
	"time"
	"github.com/pion/logging"
	"golang.org/x/net/dns/dnsmessage"
	"golang.org/x/net/ipv4"
)
type Conn struct {
	mu  sync.RWMutex
	log logging.LeveledLogger
	socket  *ipv4.PacketConn
	dstAddr *net.UDPAddr
	queryInterval time.Duration
	localNames    []string
	queries       []query
	closed chan interface{}
}
type query struct {
	nameWithSuffix  string
	queryResultChan chan queryResult
}
type queryResult struct {
	answer dnsmessage.ResourceHeader
	addr   net.Addr
}
const (
	inboundBufferSize    = 512
	defaultQueryInterval = time.Second
	destinationAddress   = "224.0.0.251:5353"
	maxMessageRecords    = 3
)
func Server(conn *ipv4.PacketConn, config *Config) (*Conn, error) {
	if config == nil {
		return nil, errNilConfig
	}
	ifaces, err := net.Interfaces()
	if err != nil {
		return nil, err
	}
	joinErrCount := 0
	for i := range ifaces {
		if err = conn.JoinGroup(&ifaces[i], &net.UDPAddr{IP: net.IPv4(224, 0, 0, 251)}); err != nil {
			joinErrCount++
		}
	}
	if joinErrCount >= len(ifaces) {
		return nil, errJoiningMulticastGroup
	}
	dstAddr, err := net.ResolveUDPAddr("udp", destinationAddress)
	if err != nil {
		return nil, err
	}
	loggerFactory := config.LoggerFactory
	if loggerFactory == nil {
		loggerFactory = logging.NewDefaultLoggerFactory()
	}
	localNames := []string{}
	for _, l := range config.LocalNames {
		localNames = append(localNames, l+".")
	}
	c := &Conn{
		queryInterval: defaultQueryInterval,
		queries:       []query{},
		socket:        conn,
		dstAddr:       dstAddr,
		localNames:    localNames,
		log:           loggerFactory.NewLogger("mdns"),
		closed:        make(chan interface{}),
	}
	if config.QueryInterval != 0 {
		c.queryInterval = config.QueryInterval
	}
	go c.start()
	return c, nil
}