#include <SocketProfilingConnection.hpp>
◆ SocketProfilingConnection()
Definition at line 21 of file SocketProfilingConnection.cpp.
References SocketProfilingConnection::Close(), armnnUtils::Sockets::Initialize(), and armnnUtils::Sockets::SetNonBlocking().
24 memset(m_Socket, 0,
sizeof(m_Socket));
26 m_Socket[0].fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
27 if (m_Socket[0].fd == -1)
29 throw armnnProfiling::SocketConnectionException(
30 std::string(
"SocketProfilingConnection: Socket construction failed: ") + strerror(errno),
37 memset(&server, 0,
sizeof(sockaddr_un));
39 memcpy(server.sun_path, m_GatorNamespace, strlen(m_GatorNamespace + 1) + 1);
40 server.sun_family = AF_UNIX;
41 if (0 != connect(m_Socket[0].fd, reinterpret_cast<const sockaddr*>(&server),
sizeof(sockaddr_un)))
44 throw armnnProfiling::SocketConnectionException(
45 std::string(
"SocketProfilingConnection: Cannot connect to stream socket: ") + strerror(errno),
51 m_Socket[0].events = POLLIN;
57 throw armnnProfiling::SocketConnectionException(
58 std::string(
"SocketProfilingConnection: Failed to set socket as non blocking: ") + strerror(errno),
bool Initialize()
Performs any required one-time setup.
bool SetNonBlocking(Socket s)
◆ Close()
◆ IsOpen()
◆ ReadPacket()
Packet ReadPacket |
( |
uint32_t |
timeout | ) |
|
|
finalvirtual |
Implements IProfilingConnection.
Definition at line 92 of file SocketProfilingConnection.cpp.
References SocketProfilingConnection::Close(), armnnUtils::Sockets::Ioctl(), armnnUtils::Sockets::Poll(), and armnnUtils::Sockets::Read().
95 int bytes_available = 0;
97 if (bytes_available >= 8)
100 return ReceivePacket();
104 int pollResult =
Sockets::Poll(&m_Socket[0], 1, static_cast<int>(timeout));
109 throw armnnProfiling::SocketConnectionException(
110 std::string(
"SocketProfilingConnection: Error occured while reading from socket: ") + strerror(errno),
115 throw TimeoutException(
"SocketProfilingConnection: Timeout while reading from socket");
119 if (m_Socket[0].revents & (POLLNVAL | POLLERR | POLLHUP))
121 if (m_Socket[0].revents == POLLNVAL)
125 throw armnnProfiling::SocketConnectionException(
126 std::string(
"SocketProfilingConnection: Error occured while polling receiving socket: POLLNVAL."),
129 if (m_Socket[0].revents == POLLERR)
131 throw armnnProfiling::SocketConnectionException(
133 "SocketProfilingConnection: Error occured while polling receiving socket: POLLERR: ")
138 if (m_Socket[0].revents == POLLHUP)
142 throw armnnProfiling::SocketConnectionException(
143 std::string(
"SocketProfilingConnection: Connection closed by remote client: POLLHUP."),
149 if (!(m_Socket[0].revents & (POLLIN)))
154 "SocketProfilingConnection: File descriptor was polled but no data was available to receive.");
157 return ReceivePacket();
int Poll(PollFd *fds, nfds_t numFds, int timeout)
int Ioctl(Socket s, unsigned long int cmd, void *arg)
◆ WritePacket()
bool WritePacket |
( |
const unsigned char * |
buffer, |
|
|
uint32_t |
length |
|
) |
| |
|
finalvirtual |
The documentation for this class was generated from the following files: