From aac7e590ea497ff05bf55e1f68713df77d9e5905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanislav=20Angelovi=C4=8D?= Date: Tue, 10 Oct 2023 19:15:21 +0200 Subject: [PATCH] docs: add recommendation on destroying direct D-Bus connections --- docs/using-sdbus-c++.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/using-sdbus-c++.md b/docs/using-sdbus-c++.md index 502d91f..90f8c51 100644 --- a/docs/using-sdbus-c++.md +++ b/docs/using-sdbus-c++.md @@ -1664,11 +1664,14 @@ int main(int argc, char *argv[]) auto concatenatedString = concatenatorProxy.concatenate(numbers, separator); assert(concatenatedString == "1:2:3"); + // Explicitly stop working on socket fd's to avoid "Connection reset by peer" errors clientConnection->leaveEventLoop(); serverConnection->leaveEventLoop(); } ``` +> **_Note_:** The example above explicitly stops the event loops on both sides, before the connection objects are destroyed. This avoids potential `Connection reset by peer` errors caused when one side closes its socket while the other side is still working on the counterpart socket. This is a recommended workflow for closing direct D-Bus connections. + Conclusion ----------