PdCom  5.0
Process data communication client
Loading...
Searching...
No Matches
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 "pdcom5_export.h"
29
30#include <chrono>
31#include <memory>
32#include <string>
33
34namespace PdCom {
35
36
44class PDCOM5_PUBLIC PosixProcess
45{
46 public:
53 PosixProcess(const char *host, unsigned short port);
54
59 explicit PosixProcess(int fd);
60
61
62 virtual ~PosixProcess();
63
64 PosixProcess(PosixProcess &&o) = delete;
65 PosixProcess(PosixProcess const &) = delete;
66
67 PosixProcess &operator=(PosixProcess &&o) = delete;
68 PosixProcess &operator=(PosixProcess const &) = delete;
69
70 protected:
72 int fd_;
73
88 void posixWriteBuffered(const char *buf, size_t count);
89
104 void posixWriteDirect(const char *buf, size_t count);
105
106
114 int posixRead(char *buf, int count);
115
124
129 void setWriteTimeout(std::chrono::milliseconds ms);
130
139 void reconnect(const char *host, unsigned short port);
140
141 private:
142 class Impl;
143 std::shared_ptr<Impl> impl_;
144};
145
146} // namespace PdCom
147
148#endif // PDCOM5_POSIXPROCESS_H
Wrapper around POSIX socket.
Definition: PosixProcess.h:45
PosixProcess(int fd)
Constructor.
PosixProcess(const char *host, unsigned short port)
Constructor.
void posixFlush()
Flush internal buffer to socket.
void posixWriteBuffered(const char *buf, size_t count)
Buffered Wrapper for write().
int fd_
File descriptior of the socket.
Definition: PosixProcess.h:72
void setWriteTimeout(std::chrono::milliseconds ms)
Timeout for posixWriteDirect() in non-blocking mode.
void posixWriteDirect(const char *buf, size_t count)
Unbuffered Wrapper for write().
int posixRead(char *buf, int count)
Wrapper for read().
void reconnect(const char *host, unsigned short port)
Establish a new connection.
library version string as "major.minor.patch"
Definition: ClientStatistics.h:31