MCPcopy
hub / github.com/grpc/grpc-go / keepReading

Function keepReading

clientconn_test.go:1018–1022  ·  clientconn_test.go::keepReading

Keep reading until something causes the connection to die (EOF, server closed, etc). Useful as a tool for mindlessly keeping the connection healthy, since the client will error if things like client prefaces are not accepted in a timely fashion.

(conn net.Conn)

Source from the content-addressed store, hash-verified

1016// healthy, since the client will error if things like client prefaces are not
1017// accepted in a timely fashion.
1018func keepReading(conn net.Conn) {
1019 buf := make([]byte, 1024)
1020 for _, err := conn.Read(buf); err == nil; _, err = conn.Read(buf) {
1021 }
1022}
1023
1024// stayConnected makes cc stay connected by repeatedly calling cc.Connect()
1025// until the state becomes Shutdown or until 10 seconds elapses.

Calls 1

ReadMethod · 0.65

Tested by

no test coverage detected