Skip to content

This is a sample of an application built in Go using SO_REUSEPORT socket option.

License

Notifications You must be signed in to change notification settings

devlights/go-socket-reuseport-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-socket-reuseport-example

This is a sample of an application built in Go using SO_REUSEPORT socket option.

Go Version

How to Run

Using go-task

Build

$ 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

Server 1

Open a new terminal and execute the following command.

$ task server -- 1

Server 2

Open a new terminal and execute the following command.

$ task server -- 2

Check LISTEN Status

$ 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:*

Client

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

Stop servers

$ task close

About

This is a sample of an application built in Go using SO_REUSEPORT socket option.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages