Skip to content

Commit

Permalink
revert changes to greeter server example
Browse files Browse the repository at this point in the history
  • Loading branch information
JaydenTeoh committed Oct 19, 2023
1 parent 0b94503 commit 3138142
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 2 additions & 1 deletion dialoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ func WithTimeout(d time.Duration) DialOption {
// should try to reconnect to the network address.
//
// Note: Go overrides the OS defaults for TCP keepalive time and interval to 15s.
// To retain OS defaults, use a net.Dialer with the KeepAlive field set to a negative value.
// To retain OS defaults, use a net.Dialer with the KeepAlive field set to a
// negative value.
func WithContextDialer(f func(context.Context, string) (net.Conn, error)) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.Dialer = f
Expand Down
5 changes: 1 addition & 4 deletions examples/helloworld/greeter_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"fmt"
"log"
"net"
"time"

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

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

0 comments on commit 3138142

Please sign in to comment.