File: ConnectionHandler.hpp

package info (click to toggle)
armnn 23.08-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 53,580 kB
  • sloc: cpp: 337,440; python: 4,755; sh: 1,708; makefile: 42; asm: 15; xml: 6
file content (48 lines) | stat: -rw-r--r-- 1,444 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#pragma once

#include "BasePipeServer.hpp"
#include <string>

namespace arm
{

namespace pipe
{

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.
        arm::pipe::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:

    arm::pipe::Socket m_ListeningSocket;
};

} // namespace pipe
} // namespace arm