本文整理匯總了Golang中github.com/miekg/dns.Client.Timeout方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Timeout方法的具體用法?Golang Client.Timeout怎麽用?Golang Client.Timeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/miekg/dns.Client
的用法示例。
在下文中一共展示了Client.Timeout方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: sendRequest
/*
* sendRequest() - send a DNS query
*/
func sendRequest(ctx *Context, m *dns.Msg, transport string, timeout time.Duration) (response *dns.Msg, rtt time.Duration, err error) {
c := new(dns.Client)
c.Timeout = timeout
c.Net = transport // "udp" or "tcp"
response, rtt, err = c.Exchange(m, addressString(ctx.server, ctx.port))
return
}
示例2: digester
func digester(server string, done <-chan struct{}, names <-chan string, output chan<- DNSResponse) {
for targetName := range names {
message := new(dns.Msg)
client := new(dns.Client)
client.Timeout = 10 * 1e9
message.SetQuestion(targetName, dns.TypeA)
response, _, err := client.Exchange(message, server+":53")
// retry errors.
if err != nil {
response, _, err = client.Exchange(message, server+":53")
}
resp := makeDNSResponse(targetName, response, err)
select {
case output <- *resp:
case <-done:
return
}
}
}