From 8440adab127e23e91aa9ecf8f151f1752cffa681 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Sun, 19 Dec 2021 11:48:32 -0700 Subject: [PATCH] refactor unix socket --- reflector/UnixDgramSocket.cpp | 5 +++++ reflector/UnixDgramSocket.h | 1 + 2 files changed, 6 insertions(+) diff --git a/reflector/UnixDgramSocket.cpp b/reflector/UnixDgramSocket.cpp index dddf4cf..ff21399 100644 --- a/reflector/UnixDgramSocket.cpp +++ b/reflector/UnixDgramSocket.cpp @@ -81,6 +81,11 @@ bool CUnixDgramReader::Receive(STCPacket *pack, unsigned timeout) const return false; } + return Read(pack); +} + +bool CUnixDgramReader::Read(STCPacket *pack) const +{ auto len = read(fd, pack, sizeof(STCPacket)); if (len != sizeof(STCPacket)) { std::cerr << "Received transcoder packet is wrong size: " << len << " but should be " << sizeof(STCPacket) << std::endl; diff --git a/reflector/UnixDgramSocket.h b/reflector/UnixDgramSocket.h index 2b06d87..1f044e7 100644 --- a/reflector/UnixDgramSocket.h +++ b/reflector/UnixDgramSocket.h @@ -28,6 +28,7 @@ public: CUnixDgramReader(); ~CUnixDgramReader(); bool Open(const char *path); + bool Read(STCPacket *pack) const; bool Receive(STCPacket *pack, unsigned timeout) const; void Close(); int GetFD() const;