2 * AxWin4 Interface Library
3 * - By John Hodge (thePowersGang)
6 * - Acess2 /Devices/ipcpipe/ IPC Channel
8 #include "include/common.hpp"
9 #include "include/CIPCChannel_AcessIPCPipe.hpp"
10 #include <system_error>
15 CIPCChannel_AcessIPCPipe::CIPCChannel_AcessIPCPipe(const char *Path)
17 m_fd = _SysOpen(Path, OPENFLAG_READ|OPENFLAG_WRITE);
19 throw ::std::system_error(errno, ::std::system_category());
23 CIPCChannel_AcessIPCPipe::~CIPCChannel_AcessIPCPipe()
27 int CIPCChannel_AcessIPCPipe::FillSelect(fd_set& fds)
33 bool CIPCChannel_AcessIPCPipe::HandleSelect(const fd_set& fds)
35 if( FD_ISSET(m_fd, &fds) )
37 ::std::vector<uint8_t> rxbuf(4096);
38 size_t len = _SysRead(m_fd, rxbuf.data(), rxbuf.capacity());
39 if( len == (size_t)-1 )
40 throw ::std::system_error(errno, ::std::system_category());
42 _SysDebug("CClient_AcessIPCPipe::HandleReceive - Rx %i/%i bytes", len, rxbuf.capacity());
43 //_SysDebugHex("CClient_AcessIPCPipe::HandleReceive", rxbuf.data(), len);
45 CDeserialiser msg(rxbuf);
46 ::AxWin::RecvMessage( msg );
51 void CIPCChannel_AcessIPCPipe::Send(CSerialiser& message)
53 const ::std::vector<uint8_t>& serialised = message.Compact();
54 if(serialised.size() > 0x1000 ) {
55 throw ::std::length_error("CIPCChannel_AcessIPCPipe::Send");
57 _SysDebug("CIPCChannel_AcessIPCPipe::Send(%i bytes)", serialised.size());
58 //_SysDebugHex("CIPCChannel_AcessIPCPipe::Send", serialised.data(), serialised.size());
60 size_t rv = _SysWrite(m_fd, serialised.data(), serialised.size());
61 if( rv != serialised.size() ) {
62 throw ::std::system_error(errno, ::std::system_category());