tidwall / evio

Fast event-loop networking for Go
MIT License
5.9k stars 492 forks source link

evio_unix will auto close the connections, when no data is read out #34

Closed sleep2death closed 5 years ago

sleep2death commented 5 years ago

System: MacOs Mojave, Serve address: tcp://localhost:8081?reuseport=true Test Code: ` var conns []net.Conn

for count := 0; count < 10; count++ { conn, err := net.Dial("tcp", "localhost:8101") conns = append(conns, conn)

if err != nil {
    log.Panic(err)
}

// time.Sleep(time.Second * time.Duration(rand.Intn(3)))

}

for index, conn := range conns { str := fmt.Sprintf("Hello, Evio, from conn: %d\n", index) conn.Write([]byte(str)) }

tidwall commented 5 years ago

evio_unix will auto close the connections, when no data is read out

Evio isn't auto-closing connections. When no data is read from syscall.Read, this means that the connection should be closed.

From: http://pubs.opengroup.org/onlinepubs/009695399/functions/read.html

If the starting position is at or after the end-of-file, 0 shall be returned.

From: http://man7.org/linux/man-pages/man2/read.2.html

On success, the number of bytes read is returned (zero indicates end of file), and the file position is advanced by this number.