From bb51e84ff02ba88cf9a968888a652402ddc96249 Mon Sep 17 00:00:00 2001 From: Tobbeman Date: Fri, 26 Feb 2021 17:53:50 +0100 Subject: [PATCH] Add return error on write actions (#104) This error can be used to detect if the connection was broken, for example if the server goes down between client sending data Co-authored-by: Tobias Laving --- .gitignore | 1 + netconf/transport.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/netconf/transport.go b/netconf/transport.go index 998e1fc..401263e 100644 --- a/netconf/transport.go +++ b/netconf/transport.go @@ -74,9 +74,9 @@ func (t *transportBasicIO) Send(data []byte) error { } dataInfo = append(dataInfo, data...) dataInfo = append(dataInfo, seperator...) - t.Write(dataInfo) + _, err := t.Write(dataInfo) - return nil // TODO: Implement error handling! + return err } func (t *transportBasicIO) Receive() ([]byte, error) {