プロジェクト
概要
Go サーバーで SO_REUSEPORT を利用可能にします
その他のプロジェクト計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルGO_REUSEPORT
GO_REUSEPORT is a little expirement to create a net.Listener that supports SO_REUSEPORT socket option.
For now, Darwin and Linux (from 3.9) systems are supported. I'll be pleased if you'll test other systems and tell me the results. documentation on godoc.org.
Example
package main
import (
"fmt"
"html"
"net/http"
"os"
"runtime"
"github.com/kavu/go_reuseport"
)
func main() {
listener, err := reuseport.Listen("tcp", "localhost:8881")
if err != nil {
panic(err)
}
defer listener.Close()
server := &http.Server{}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Println(os.Getgid())
fmt.Fprintf(w, "Hello, %q\n", html.EscapeString(r.URL.Path))
})
panic(server.Serve(listener))
}
Now you can run several instances of this tiny server without Address already in use errors.
Thanks
Inspired by Artur Siekielski post about SO_REUSEPORT.
関連プロジェクトを探す
読み込み中…

