-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDNS-test.go
39 lines (34 loc) · 1021 Bytes
/
DNS-test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"fmt"
"net"
//"time"
"context"
//"google.golang.org/grpc"
)
func dialContext(ctx context.Context, network, address string) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, network, address)
}
func main(){
var ctx context.Context
var network,address string
network = "tcp"
//address = "www.github.com:443"
address = "127.0.0.1:22"
ctx = context.Background()
//ctx, cancel := context.WithTimeout(context.Background(), time.Second)
//defer cancel()
fmt.Print("ctx = ", ctx)
fmt.Println(" ")
fmt.Print("network = ", network)
fmt.Println(" ")
fmt.Print("address = ", address)
fmt.Println(" ")
_,err := dialContext(ctx, network, address)
if(err != nil) {
fmt.Print("err = ", err)
fmt.Println(" ")
fmt.Println("dialContext error!\n")
}
return;
}