Question

When using socket communication in PHP, do I need to confirm if a message has been successfully received after sending each message? Or would the transport layer (TCP) take care of error detection and correction, ensuring successful delivery of any sent messages?

Was it helpful?

Solution

You don't need to worry about such things on this level. Once you write the data into an open socket, you can be sure that it will eventually arrive correctly (assuming there is a route between the end points). What you should take care of is the return values of socket functions. Check all return values of the socket_* functions for a reliable communication.

OTHER TIPS

TCP handles error detection and correction as far as it goes. There isn't really such a thing as ensuring successful delivery (cf. backhoe fade), so there's some level at which you need to take into account the possibility that a message will not be delivered.

You can safely believe that the data has been successfully received if the php function does not point out any specific error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top