-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get write response #255
Comments
@leocharrua Thanks for bringing this up, this is an interesting question! This packages is entirely asynchronous and event-driven, so one first has to get used to a different kind of control flow. The If the server properly closes a connection, it would send a TCP/IP FIN flag. The client would detect this and emit a $connection->on('close', function () {
echo 'Connection closed' . PHP_EOL;
}); A successful $connection->on('error', function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
}); Keep in mind that connections can also be interrupted (think hard power down), so the server may have no chance to send a FIN to the client. In this case, you would probably want to apply some kind of higher level protocol to send keepalive messages (heartbeats). If you don't receive a reply in x seconds, you can manually I hope this helps 👍 |
Excelent @clue . Very clear answer. Thanks for all your work. |
Hello, I know all here is non-blocking and is ok. But, how I can get the result after I do a write tcp package?
For example, I has a tcp connection with the server, but in some point, the server get down. The client do the write, but didn't get any advice that the connection is down.
I'm checking the connection on('error') event, but I didn't get anything there.
Thanks for your help.
The text was updated successfully, but these errors were encountered: