https://github.com/gogf/greuse
Package greuse provides Listen and Dial functions that set socket options in order to be able to reuse ports. You should only use this package if you know what SO_REUSEADDR and SO_REUSEPORT are.
https://github.com/gogf/greuse
gf goframe reuseaddr reuseport tcp
Last synced: about 1 year ago
JSON representation
Package greuse provides Listen and Dial functions that set socket options in order to be able to reuse ports. You should only use this package if you know what SO_REUSEADDR and SO_REUSEPORT are.
- Host: GitHub
- URL: https://github.com/gogf/greuse
- Owner: gogf
- License: mit
- Created: 2019-03-18T05:42:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-06T04:02:59.000Z (over 6 years ago)
- Last Synced: 2025-04-20T08:09:53.872Z (about 1 year ago)
- Topics: gf, goframe, reuseaddr, reuseport, tcp
- Language: Go
- Homepage: https://goframe.org
- Size: 11.7 KB
- Stars: 60
- Watchers: 5
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# greuse
Package greuse provides Listen and Dial functions that set socket options in order to be able to reuse ports.
You should only use this package if you know what SO_REUSEADDR and SO_REUSEPORT are.
# Installation
```
go get -u -v github.com/gogf/greuse
```
or use `go.mod`
```
require github.com/gogf/greuse latest
```
# Documentation
* [https://godoc.org/github.com/gogf/greuse](https://godoc.org/github.com/gogf/greuse)
# Quick Start
```go
package main
import (
"fmt"
"github.com/gogf/greuse"
"net/http"
"os"
)
// We can create two processes with this code.
// Do some requests, then watch the output of the console.
func main() {
listener, err := greuse.Listen("tcp", ":8881")
if err != nil {
panic(err)
}
defer listener.Close()
server := &http.Server{}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "gid: %d, pid: %d\n", os.Getgid(), os.Getpid())
})
panic(server.Serve(listener))
}
```
# License
`greuse` is licensed under the [MIT License](LICENSE), 100% free and open-source, forever.