#include <SocketProfilingConnection.hpp>
◆ SocketProfilingConnection()
Definition at line 20 of file SocketProfilingConnection.cpp.
References SocketProfilingConnection::Close().
22 arm::pipe::Initialize();
23 memset(m_Socket, 0,
sizeof(m_Socket));
25 m_Socket[0].fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
26 if (m_Socket[0].fd == -1)
28 throw arm::pipe::SocketConnectionException(
29 std::string(
"SocketProfilingConnection: Socket construction failed: ") + strerror(errno),
36 memset(&server, 0,
sizeof(sockaddr_un));
38 memcpy(server.sun_path, m_GatorNamespace, strlen(m_GatorNamespace + 1) + 1);
39 server.sun_family = AF_UNIX;
40 if (0 != connect(m_Socket[0].fd, reinterpret_cast<const sockaddr*>(&server),
sizeof(sockaddr_un)))
43 throw arm::pipe::SocketConnectionException(
44 std::string(
"SocketProfilingConnection: Cannot connect to stream socket: ") + strerror(errno),
50 m_Socket[0].events = POLLIN;
53 if (!arm::pipe::SetNonBlocking(m_Socket[0].fd))
56 throw arm::pipe::SocketConnectionException(
57 std::string(
"SocketProfilingConnection: Failed to set socket as non blocking: ") + strerror(errno),
◆ Close()
◆ IsOpen()
◆ ReadPacket()
arm::pipe::Packet ReadPacket |
( |
uint32_t |
timeout | ) |
|
|
finalvirtual |
Implements IProfilingConnection.
Definition at line 91 of file SocketProfilingConnection.cpp.
References SocketProfilingConnection::Close().
94 int bytes_available = 0;
95 arm::pipe::Ioctl(m_Socket[0].fd, FIONREAD, &bytes_available);
96 if (bytes_available >= 8)
99 return ReceivePacket();
103 int pollResult = arm::pipe::Poll(&m_Socket[0], 1, static_cast<int>(timeout));
108 throw arm::pipe::SocketConnectionException(
109 std::string(
"SocketProfilingConnection: Error occured while reading from socket: ") + strerror(errno),
114 throw arm::pipe::TimeoutException(
"SocketProfilingConnection: Timeout while reading from socket");
118 if (m_Socket[0].revents & (POLLNVAL | POLLERR | POLLHUP))
120 if (m_Socket[0].revents == POLLNVAL)
124 throw arm::pipe::SocketConnectionException(
125 std::string(
"SocketProfilingConnection: Error occured while polling receiving socket: POLLNVAL."),
128 if (m_Socket[0].revents == POLLERR)
130 throw arm::pipe::SocketConnectionException(
132 "SocketProfilingConnection: Error occured while polling receiving socket: POLLERR: ")
137 if (m_Socket[0].revents == POLLHUP)
141 throw arm::pipe::SocketConnectionException(
142 std::string(
"SocketProfilingConnection: Connection closed by remote client: POLLHUP."),
148 if (!(m_Socket[0].revents & (POLLIN)))
153 "SocketProfilingConnection: File descriptor was polled but no data was available to receive.");
156 return ReceivePacket();
◆ WritePacket()
bool WritePacket |
( |
const unsigned char * |
buffer, |
|
|
uint32_t |
length |
|
) |
| |
|
finalvirtual |
The documentation for this class was generated from the following files: