I am trying to create a fairly simple http file server in Go. Ideally, it should be able to support multiple concurrent file downloads from 2 to 20 clients simultaneously.
I have tried several different approaches including the using the "net/http" and "gorilla" libraries with the same unsuccessful results: the first two clients connect and begin downloading the file normally. Any additional connections fail until one of the first two completes.
Is there a maximum number of concurrent connections / downloads of the same file and can this be increased?
- Operating system: Windows 10 Enterprise - max 2 concurrent
- Operating system: Ubuntu 22.04 - unknown max, but at least 15
- Operating system: Raspbian v11 - unknown max, but at least 15
Very simplified code example below:
package main
import (
"log"
"net/http"
)
func main() {
log.Printf("\nListening... [:80]")
mux := http.NewServeMux()
mux.Handle("/", http.FileServer(http.Dir(".")))
if err := http.ListenAndServe(":80", mux); err != nil {
log.Fatalf("Could not start server: \n %v", err)
}
}