This is a sample of an application built in Go using SO_REUSEPORT socket option.
Using go-task
$ task build
task: [clean] rm -rf bin
task: [build] go build -o bin/server cmd/server/main.go
task: [build] go build -o bin/client cmd/client/main.go
Open a new terminal and execute the following command.
$ task server -- 1
Open a new terminal and execute the following command.
$ task server -- 2
$ task ss
task: [ss] ss -atn | grep -F "0.0.0.0:9999"
LISTEN 0 128 0.0.0.0:9999 0.0.0.0:*
LISTEN 0 128 0.0.0.0:9999 0.0.0.0:*
Open a new terminal and execute the following command.
$ task client
task: [client] for i in {1..10}; do bin/client; done
RESPONSE FROM: 2
RESPONSE FROM: 1
RESPONSE FROM: 1
RESPONSE FROM: 1
RESPONSE FROM: 2
RESPONSE FROM: 1
RESPONSE FROM: 1
RESPONSE FROM: 2
RESPONSE FROM: 1
RESPONSE FROM: 1
$ task close