blob: fceaa0f697e0e0e81c2c9d3d3ebfc4d66d418226 [file] [log] [blame]
Sadik Armagana97a0be2020-03-03 10:44:56 +00001//
2// Copyright © 2020 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#pragma once
6
7#include <sstream>
8#include <stdexcept>
9#include <string>
10
Rob Hughesb98032f2020-04-24 11:41:34 +010011#include "NetworkSockets.hpp"
12
Sadik Armagana97a0be2020-03-03 10:44:56 +000013namespace armnnProfiling
14{
15
16/// Socket Connection Exception for profiling
17class SocketConnectionException : public std::exception
18{
19public:
Rob Hughesb98032f2020-04-24 11:41:34 +010020 explicit SocketConnectionException(const std::string& message, armnnUtils::Sockets::Socket socket)
Sadik Armagana97a0be2020-03-03 10:44:56 +000021 : m_Message(message), m_Socket(socket), m_ErrNo(-1)
22 {};
23
Rob Hughesb98032f2020-04-24 11:41:34 +010024 explicit SocketConnectionException(const std::string& message, armnnUtils::Sockets::Socket socket, int errNo)
Sadik Armagana97a0be2020-03-03 10:44:56 +000025 : m_Message(message), m_Socket(socket), m_ErrNo(errNo)
26 {};
27
28 /// @return - Error message of SocketProfilingConnection
29 virtual const char* what() const noexcept override
30 {
31 return m_Message.c_str();
32 }
33
34 /// @return - Socket File Descriptor of SocketProfilingConnection
35 /// or '-1', an invalid file descriptor
Rob Hughesb98032f2020-04-24 11:41:34 +010036 armnnUtils::Sockets::Socket GetSocketFd() const noexcept
Sadik Armagana97a0be2020-03-03 10:44:56 +000037 {
38 return m_Socket;
39 }
40
41 /// @return - errno of SocketProfilingConnection
42 int GetErrorNo() const noexcept
43 {
44 return m_ErrNo;
45 }
46
47private:
48 std::string m_Message;
Rob Hughesb98032f2020-04-24 11:41:34 +010049 armnnUtils::Sockets::Socket m_Socket;
Sadik Armagana97a0be2020-03-03 10:44:56 +000050 int m_ErrNo;
51};
52
53} // namespace armnnProfiling