grpc-go/examples/features/dualstack
Arjan Singh Bal 65c6718afb
examples/features/dualstack: Demonstrate Dual Stack functionality (#8098)
2025-02-21 12:12:25 +05:30
..
client examples/features/dualstack: Demonstrate Dual Stack functionality (#8098) 2025-02-21 12:12:25 +05:30
server examples/features/dualstack: Demonstrate Dual Stack functionality (#8098) 2025-02-21 12:12:25 +05:30
README.md examples/features/dualstack: Demonstrate Dual Stack functionality (#8098) 2025-02-21 12:12:25 +05:30

README.md

Dualstack

The dualstack example uses a custom name resolver that provides both IPv4 and IPv6 localhost endpoints for each of 3 server instances. The client will first use the default name resolver and load balancers which will only connect to the first server. It will then use the custom name resolver with round robin to connect to each of the servers in turn. The 3 instances of the server will bind respectively to: both IPv4 and IPv6, IPv4 only, and IPv6 only.

Three servers are serving on the following loopback addresses:

  1. [::]:50052: Listening on both IPv4 and IPv6 loopback addresses.
  2. 127.0.0.1:50050: Listening only on the IPv4 loopback address.
  3. [::1]:50051: Listening only on the IPv6 loopback address.

The server response will include its serving port and address type (IPv4, IPv6 or both). So the server on "127.0.0.1:50050" will reply to the RPC with the following message: Greeting:Hello request:1 from server<50052> type: IPv4 only).

Try it

go run server/main.go
go run client/main.go