https://github.com/devlights/go-socket-reuseport-example
This is a sample of an application built in Go using SO_REUSEPORT socket option.
https://github.com/devlights/go-socket-reuseport-example
Last synced: 2 months ago
JSON representation
This is a sample of an application built in Go using SO_REUSEPORT socket option.
- Host: GitHub
- URL: https://github.com/devlights/go-socket-reuseport-example
- Owner: devlights
- License: mit
- Created: 2023-02-08T08:36:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-08T16:16:38.000Z (over 2 years ago)
- Last Synced: 2025-02-12T08:58:25.694Z (4 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-socket-reuseport-example
This is a sample of an application built in Go using SO_REUSEPORT socket option.

## How to Run
### Using [go-task](https://taskfile.dev/)
### Build
```sh
$ 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.
```sh
$ task server -- 1
```### Server 2
Open a new terminal and execute the following command.
```sh
$ task server -- 2
```### Check LISTEN Status
```sh
$ 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.
```sh
$ 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
```sh
$ task close
```