PdCom  5.3
Process data communication client
PosixProcess.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vim:tw=78
3  *
4  * Copyright (C) 2021 Bjarne von Horn (vh at igh dot de).
5  *
6  * This file is part of the PdCom library.
7  *
8  * The PdCom library is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * The PdCom library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
20  *
21  *****************************************************************************/
22 
25 #ifndef PDCOM5_POSIXPROCESS_H
26 #define PDCOM5_POSIXPROCESS_H
27 
28 #include <chrono>
29 #include <memory>
30 #include <pdcom5_export.h>
31 #include <string>
32 
33 namespace PdCom {
34 
35 
43 class PDCOM5_PUBLIC PosixProcess
44 {
45  public:
52  PosixProcess(const char *host, unsigned short port);
53 
58  explicit PosixProcess(int fd);
59 
60 
61  virtual ~PosixProcess();
62 
63  PosixProcess(PosixProcess &&o) = delete;
64  PosixProcess(PosixProcess const &) = delete;
65 
66  PosixProcess &operator=(PosixProcess &&o) = delete;
67  PosixProcess &operator=(PosixProcess const &) = delete;
68 
69  protected:
71  int fd_;
72 
87  void posixWriteBuffered(const char *buf, size_t count);
88 
103  void posixWriteDirect(const char *buf, size_t count);
104 
105 
113  int posixRead(char *buf, int count);
114 
122  void posixFlush();
123 
128  void setWriteTimeout(std::chrono::milliseconds ms);
129 
138  void reconnect(const char *host, unsigned short port);
139 
140  private:
141  class Impl;
142  std::shared_ptr<Impl> impl_;
143 };
144 
145 } // namespace PdCom
146 
147 #endif // PDCOM5_POSIXPROCESS_H
Wrapper around POSIX socket.
Definition: PosixProcess.h:43
Definition: ClientStatistics.h:31
int fd_
File descriptior of the socket.
Definition: PosixProcess.h:71