@@ -52,16 +52,24 @@ type Server struct {
5252 Gsrv * grpc.Server
5353}
5454
55- // NewServer creates a new Server. The Server will be listening for gRPC connections
56- // at the address named by the Addr field, without TLS.
55+ // NewServer creates a new Server on localhost . The Server will be listening for
56+ // gRPC connections at the address named by the Addr field, without TLS.
5757func NewServer (opts ... grpc.ServerOption ) (* Server , error ) {
5858 return NewServerWithPort (0 , opts ... )
5959}
6060
61- // NewServerWithPort creates a new Server at a specific port. The Server will be listening
62- // for gRPC connections at the address named by the Addr field, without TLS.
61+ // NewServerWithPort creates a new Server on localhost at a specific port. The
62+ // Server will be listening for gRPC connections at the address named by the
63+ // Addr field, without TLS.
6364func NewServerWithPort (port int , opts ... grpc.ServerOption ) (* Server , error ) {
64- l , err := net .Listen ("tcp" , fmt .Sprintf ("localhost:%d" , port ))
65+ return NewServerWithAddress (fmt .Sprintf ("localhost:%d" , port ))
66+ }
67+
68+ // NewServerWithAddress creates a new Server with a specific address (host and
69+ // port). The Server will be listening for gRPC connections at the address named
70+ // by the Addr field, without TLS.
71+ func NewServerWithAddress (addr string , opts ... grpc.ServerOption ) (* Server , error ) {
72+ l , err := net .Listen ("tcp" , addr )
6573 if err != nil {
6674 return nil , err
6775 }
0 commit comments