去套接字服务器出现EOF错误?

My codes:

    var connMax int = 0

    func CheckErr(err error) {
        if err != nil {
            fmt.Fprintf(os.Stderr, "Error occured: %s
", err)
            os.Exit(1)
        }
    }

    func handler(conn net.Conn) {
        defer conn.Close()

        var buf [512]byte
        n, err := conn.Read(buf[0:])
        CheckErr(err)

        connMax += 1
        fmt.Println(connMax)

        result := bytes.NewBuffer(nil)
        result.Write(buf[0:n])

        fmt.Println(string(result.Bytes()))

        conn.Write([]byte("HTTP/1.1 201 OK
"))

    func Run() {
        ln, err := net.Listen("tcp", ":8080")
        CheckErr(err)
        for {
            conn, err := ln.Accept()
            CheckErr(err)
            go handler(conn)
        }
    }

I tried to testing server with command ab of package apache2-utils. ab -c 1500 -n 10000 http://127.0.0.1:8080/

once that finished, EOF error occured, so process exit: enter image description here

io.EOF indicates that the connection is closed by the other end. I guess it's because ab reaches the limitation of open file descriptors, so the connection is closed. Use ulimit -a to check it. If it's less than 10000, use ulimit -n 65536 to change it. This is to allow more than 10000 connections. I choose 65536 randomly, and you need root privilege to do this configure.