Woman, Life, Freedom


Async BSD Sockets Library
Library protected and public interface header documentation
 
Loading...
Searching...
No Matches
fifo_receiver.h
1#ifndef FIFO_RECEIVER_H
2#define FIFO_RECEIVER_H
3
4#include <sys/stat.h>
5#include <string>
6#include <array>
7#include "./communicator.h"
8
9namespace AsyncBsdSocketLib
10{
12 class FifoReceiver : public Communicator
13 {
14 private:
15 const std::string mPathname;
16
17 public:
18 FifoReceiver() = delete;
19
22 FifoReceiver(std::string pathname);
23
24 int Connection() const noexcept override;
25
26 bool TrySetup() noexcept override;
27
33 template <std::size_t N>
34 ssize_t Receive(std::array<uint8_t, N> &buffer) const noexcept
35 {
36 ssize_t _result = read(FileDescriptor, buffer.data(), N);
37
38 return _result;
39 }
40 };
41}
42
43#endif
int FileDescriptor
File descriptor.
Definition communicator.h:13
ssize_t Receive(std::array< uint8_t, N > &buffer) const noexcept
Receive a byte array from the FIFO pipe.
Definition fifo_receiver.h:34
FifoReceiver(std::string pathname)
Constructor.
bool TrySetup() noexcept override
Try to setup the communicator.
int Connection() const noexcept override
Connection descriptor for sending and receiving.