func (pool *DopplerPool) getClient(key, url string) loggregatorclient.Client {
	var client loggregatorclient.Client
	if client = pool.clients[key]; client == nil {
		return nil
	}

	// scheme://address
	if !((len(url) == len(client.Scheme())+3+len(client.Address())) &&
		strings.HasPrefix(url, client.Scheme()) && strings.HasSuffix(url, client.Address())) {
		return nil
	}

	return client
}
import (
	"net"
	"strconv"

	"github.com/cloudfoundry/gosteno"
	"github.com/cloudfoundry/loggregatorlib/loggregatorclient"

	. "github.com/onsi/ginkgo"
	"github.com/onsi/ginkgo/config"
	. "github.com/onsi/gomega"
)

var _ = Describe("Udp Client", func() {
	var (
		client             loggregatorclient.Client
		udpListener        *net.UDPConn
		loggregatorAddress string
	)

	BeforeEach(func() {
		port := 9875 + config.GinkgoConfig.ParallelNode
		loggregatorAddress = net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
		var err error
		client, err = loggregatorclient.NewUDPClient(gosteno.NewLogger("TestLogger"), loggregatorAddress, 0)
		Expect(err).NotTo(HaveOccurred())

		udpAddr, _ := net.ResolveUDPAddr("udp", loggregatorAddress)
		udpListener, _ = net.ListenUDP("udp", udpAddr)
	})

	AfterEach(func() {