31 lines
467 B
Go
31 lines
467 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net"
|
|
"runtime"
|
|
|
|
grpc "google.golang.org/grpc"
|
|
)
|
|
|
|
const (
|
|
port = "20051"
|
|
)
|
|
|
|
func CreateServer() {
|
|
//起服务
|
|
listen, err := net.Listen("tcp", "localhost:"+port)
|
|
if err != nil {
|
|
log.Fatalf("failed to listen: %v", err)
|
|
}
|
|
gserver := grpc.NewServer()
|
|
RegisterEasyDataServer(gserver, &server{})
|
|
gserver.Serve(listen)
|
|
// time.Sleep(time.Millisecond * 50)
|
|
}
|
|
|
|
func main() {
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
CreateServer()
|
|
}
|