diff options
author | Finn Williams <Finn.Williams@arm.com> | 2020-04-20 21:21:07 +0100 |
---|---|---|
committer | Finn Williams <Finn.Williams@arm.com> | 2020-04-27 20:50:53 +0100 |
commit | 2ed809cb4765306b7af9b6968e2ec609d143979b (patch) | |
tree | a26b4d4e841434802c01b11a202ec58acf3cd61f /profiling/server/src/basePipeServer/ConnectionHandler.hpp | |
parent | 4e755a50e35a1f5ac1b011dc4baf89e6d97f116e (diff) | |
download | armnn-2ed809cb4765306b7af9b6968e2ec609d143979b.tar.gz |
IVGCVSW-4594 Refactor the GatordMockService and GatordMockMain to extract a BasePipeServer
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: I03c1b46104dadc491dba6075865e486f78aa60fa
Diffstat (limited to 'profiling/server/src/basePipeServer/ConnectionHandler.hpp')
-rw-r--r-- | profiling/server/src/basePipeServer/ConnectionHandler.hpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/profiling/server/src/basePipeServer/ConnectionHandler.hpp b/profiling/server/src/basePipeServer/ConnectionHandler.hpp new file mode 100644 index 0000000000..e7317dc355 --- /dev/null +++ b/profiling/server/src/basePipeServer/ConnectionHandler.hpp @@ -0,0 +1,45 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include "../../../../src/armnnUtils/NetworkSockets.hpp" +#include "BasePipeServer.hpp" +#include <string> + +namespace armnnProfiling +{ + +class ConnectionHandler +{ +public: + /// Constructor establishes the Unix domain socket and sets it to listen for connections. + /// @param udsNamespace the namespace (socket address) associated with the listener. + /// @throws SocketConnectionException if the socket has been incorrectly setup. + ConnectionHandler(const std::string& udsNamespace, const bool setNonBlocking); + + ~ConnectionHandler() + { + // We have set SOCK_CLOEXEC on this socket but we'll close it to be good citizens. + armnnUtils::Sockets::Close(m_ListeningSocket); + } + + ConnectionHandler(const ConnectionHandler&) = delete; + ConnectionHandler& operator=(const ConnectionHandler&) = delete; + + ConnectionHandler(ConnectionHandler&&) = delete; + ConnectionHandler& operator=(ConnectionHandler&&) = delete; + + /// Attempt to open a new socket to the client and use it to construct a new basePipeServer + /// @param echoPackets if true the raw packets will be printed to stdout. + /// @return if successful a unique_ptr to a basePipeServer otherwise a nullptr + std::unique_ptr<BasePipeServer> GetNewBasePipeServer(const bool echoPackets); + +private: + + armnnUtils::Sockets::Socket m_ListeningSocket; +}; + +} // namespace armnnProfiling
\ No newline at end of file |