Example #1
0
func main() {
	m, err := tcpmap.Lookup("www.example.org:80")
	if err != nil {
		fmt.Println("Lookup error", err)
		return
	}
	ip, err := m.Get(false)
	if err != nil {
		fmt.Println("TCMMap.Get error", err)
		return
	}
	fmt.Println("m.Get got", ip)
}
Example #2
0
// New - initalize dial.Dialer wrapper
func New(d net.Dialer, address, port string, cPoolInitial, cPoolMax int) (dialer *Dialer, err error) {
	dialer = &Dialer{
		Dialer: d,
	}
	p, err := tcpmap.Lookup(net.JoinHostPort(address, port))
	if err != nil {
		return nil, err
	}
	dialer.aPool = p
	cp, err := pool.NewChannelPool(cPoolInitial, cPoolMax,
		func() (net.Conn, error) { return dialer.dialFactory("tcp", address) })
	if err != nil {
		return nil, err
	}
	dialer.cPool = cp
	logrus.Debugf("net.Dialer initialized with %s", dialer)
	return dialer, nil
}