Open kolinfluence opened 1 year ago
@tidwall i've modified the code for reuse port to work BUT it's not elegant.
been using this package and i can only say it's great! thx!
Sorry, but unfortunately I don't have the available time necessary to dedicate to new features for this project.
@tidwall i have done the below coding. would like your guidance on how u would like call the reuse port and "add context" in. to add the feature is 15-20 mins of ur time. if u find the time in any coffee breaks, do hope to see it implemented.
only needing to add these two codes BUT not sure how u would let users define it.
config = &net.ListenConfig{Control: func (network, address string, conn syscall.RawConn) error {
return conn.Control(func(descriptor uintptr) {
unix.SetsockoptInt(int(descriptor), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
})
}}
// ListenServeAndSignal serves incoming connections and passes nil or error
// when listening. signal can be nil.
func (s *Server) ListenServeAndSignal(signal chan error) error {
//if port reuse option selected, use the config.Listen addition above. else normal net stuff
//the context.Background() can also be a user-defined option
ln, err := config.Listen(context.Background(), s.net, s.laddr)
if err != nil {
if signal != nil {
signal <- err
}
return err
}
s.mu.Lock()
s.ln = ln
s.mu.Unlock()
if signal != nil {
signal <- nil
}
return serve(s)
}
possible to do a reuse port option?
how do i modify the code for reuse port to work?