Search code examples
tcpwebsocket

Why network service build on tcp need ping pong logic?


I currently use websocket, and in rfc6455:

Upon receipt of a Ping frame, an endpoint MUST send a Pong frame in response, unless it already received a Close frame. It SHOULD respond with Pong frame as soon as is practical.

Websocket prefer a Pong respond to Ping. But if a Ping can send success over a tcp connection, should this mean the connection is still alive, why need remote to respond with a Pong.


Solution

  • I found a similar questions. Application layer need Ping Pong maybe because when call send, we can only know data is copied to the network stack successfully, and tcp layer doesn't report to us when the data is really transferred.

    Maybe someone can explain the design more detail...