Exemple #1
0
func NewClient(host string, config *tls.Config) (*Client, error) {
	proto, address := utils.ParseAddr(host)
	conn, err := tls.Dial(proto, address, config)
	if err != nil {
		return nil, err
	}
	return &Client{rpc.NewClient(conn)}, nil
}
Exemple #2
0
func serveAPI() {
	rpc.Register(new(Api))
	proto, address := utils.ParseAddr(opts.hosts[0])
	var err error
	listener, err = tls.Listen(proto, address, opts.config)
	if err != nil {
		log.Fatalf("Listen: %v", err)
	}
	defer listener.Close()
	for {
		conn, err := listener.Accept()
		if err != nil {
			log.Fatalf("Accept: %v", err)
			return
		}
		go handle(conn)
	}
}