35 #include "remotecontrolportapi.pb.h" 37 #include <sys/socket.h> 38 #include <arpa/inet.h> 42 u32MessageSizeBytes_{},
49 if(u32MessageSizeBytes_ == 0)
54 length = recv(iFd,buf,4 - message_.size(),MSG_DONTWAIT);
66 message_.insert(message_.end(),&buf[0],&buf[length]);
69 if(message_.size() == 4)
71 u32MessageSizeBytes_ = ntohl(*reinterpret_cast<std::uint32_t *>(&message_[0]));
76 if(!u32MessageSizeBytes_)
85 ssize_t length{recv(iFd,
87 u32MessageSizeBytes_ - message_.size() >
sizeof(buf) ?
88 sizeof(buf) : u32MessageSizeBytes_ - message_.size(),
96 message_.insert(message_.end(),&buf[0],&buf[length]);
99 if(message_.size() == u32MessageSizeBytes_)
103 if(!request.ParseFromArray(&message_[0],message_.size()))
112 std::uint32_t u32MessageFrameLength = htonl(sSerialization.size());
116 {
reinterpret_cast<char *
>(&u32MessageFrameLength),
sizeof(u32MessageFrameLength)},
117 {
const_cast<char *
>(sSerialization.c_str()),sSerialization.size()}
124 u32MessageSizeBytes_ = 0;
static std::string process(const EMANERemoteControlPortAPI::Request &request, std::uint32_t u32Sequence)