Giter Site home page Giter Site logo

go-socket-reuseport-example's Introduction

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

go-socket-reuseport-example's People

Contributors

devlights avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.