I found an example to limit the number of connections for a listener:
import "golang.org/x/net/netutil"//Within  net/netutil/listen.go//func 
LimitListener(l net.Listener, n int) net.Listener 
connectionCount := 2
l, err := net.Listen("tcp", ":8000")if err != nil {
    log.Fatalf("Listen: %v", err)
}
defer l.Close()
l = netutil.LimitListener(l, connectionCount)
log.Fatal(http.Serve(l, nil))

BUT I'm not using net.Listen() and http.Serve().  I'm using the 
ListenAndServeTLS().

A closer look into ListenAndServeTLS:
func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error
{
...
tlsListener := tls.NewListener(tcpKeepAliveListener{ln.(*net.TCPListener)}, 
config)
return srv.Serve(tlsListener)
}

How can I fetch the srv's tlsListener and then apply the 
netutil.LimitListener()?
ie.
netutil.LimitListener(srv.tlsListener, connectionCount)?

I'm doing my best not to tweak/recompile golang's sources to introduce this 
limitlistener feature to a tls server.
I was hoping someone had a trick to avoid that.

Thank you.

David Marceau


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to