Skip to content

Commit 3138142

Browse files
committed
revert changes to greeter server example
1 parent 0b94503 commit 3138142

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

dialoptions.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ func WithTimeout(d time.Duration) DialOption {
415415
// should try to reconnect to the network address.
416416
//
417417
// Note: Go overrides the OS defaults for TCP keepalive time and interval to 15s.
418-
// To retain OS defaults, use a net.Dialer with the KeepAlive field set to a negative value.
418+
// To retain OS defaults, use a net.Dialer with the KeepAlive field set to a
419+
// negative value.
419420
func WithContextDialer(f func(context.Context, string) (net.Conn, error)) DialOption {
420421
return newFuncDialOption(func(o *dialOptions) {
421422
o.copts.Dialer = f

examples/helloworld/greeter_server/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"fmt"
2626
"log"
2727
"net"
28-
"time"
2928

3029
"google.golang.org/grpc"
3130
pb "google.golang.org/grpc/examples/helloworld/helloworld"
@@ -48,9 +47,7 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe
4847

4948
func main() {
5049
flag.Parse()
51-
// Setting KeepAlive to -1 allows the listener to retain OS default TCP keepalive time and interval.
52-
lc := net.ListenConfig{KeepAlive: time.Duration(-1)}
53-
lis, err := lc.Listen(context.Background(), "tcp", fmt.Sprintf(":%d", *port))
50+
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
5451
if err != nil {
5552
log.Fatalf("failed to listen: %v", err)
5653
}

0 commit comments

Comments
 (0)