blob: 9ef9d98c391de6afb6c79a4b407c2fc1cd813fe6 [file] [log] [blame]
package main
import (
"bufio"
"fmt"
"log"
"net"
"time"
"v.io/x/ref/examples/grpc-fortune/vgrpc"
)
const (
secure = true
)
func main() {
conn, err := net.Dial("tcp", "localhost:8080")
if err != nil {
panic(err)
}
if secure {
vcred := &vgrpc.VanadiumCred{}
secureConn, _, _ := vcred.ClientHandshake("", conn, time.Minute)
conn = secureConn
}
fmt.Fprintf(conn, "Hello.")
status, err := bufio.NewReader(conn).ReadString('\n')
log.Printf("Client received: %s\n", status)
time.Sleep(5 * time.Second)
fmt.Fprintf(conn, "World.")
status, err = bufio.NewReader(conn).ReadString('\n')
log.Printf("Client received: %s\n", status)
}