Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 1 | // |
| 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 Hughes | b98032f | 2020-04-24 11:41:34 +0100 | [diff] [blame] | 11 | #include "NetworkSockets.hpp" |
| 12 | |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 13 | namespace armnnProfiling |
| 14 | { |
| 15 | |
| 16 | /// Socket Connection Exception for profiling |
| 17 | class SocketConnectionException : public std::exception |
| 18 | { |
| 19 | public: |
Rob Hughes | b98032f | 2020-04-24 11:41:34 +0100 | [diff] [blame] | 20 | explicit SocketConnectionException(const std::string& message, armnnUtils::Sockets::Socket socket) |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 21 | : m_Message(message), m_Socket(socket), m_ErrNo(-1) |
| 22 | {}; |
| 23 | |
Rob Hughes | b98032f | 2020-04-24 11:41:34 +0100 | [diff] [blame] | 24 | explicit SocketConnectionException(const std::string& message, armnnUtils::Sockets::Socket socket, int errNo) |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 25 | : 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 Hughes | b98032f | 2020-04-24 11:41:34 +0100 | [diff] [blame] | 36 | armnnUtils::Sockets::Socket GetSocketFd() const noexcept |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 37 | { |
| 38 | return m_Socket; |
| 39 | } |
| 40 | |
| 41 | /// @return - errno of SocketProfilingConnection |
| 42 | int GetErrorNo() const noexcept |
| 43 | { |
| 44 | return m_ErrNo; |
| 45 | } |
| 46 | |
| 47 | private: |
| 48 | std::string m_Message; |
Rob Hughes | b98032f | 2020-04-24 11:41:34 +0100 | [diff] [blame] | 49 | armnnUtils::Sockets::Socket m_Socket; |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 50 | int m_ErrNo; |
| 51 | }; |
| 52 | |
| 53 | } // namespace armnnProfiling |