Wrapper around POSIX socket.
More...
#include <PosixProcess.h>
|
int | fd_ |
| File descriptior of the socket.
|
|
Wrapper around POSIX socket.
You can derive from this class to use POSIX socket with your Process instance.
- Examples:
- advanced_example.cpp, gnutls_example.cpp, and sasl_example.cpp.
◆ PosixProcess() [1/2]
PdCom::PosixProcess::PosixProcess |
( |
const char * |
host, |
|
|
unsigned short |
port |
|
) |
| |
Constructor.
- Parameters
-
host | Host, can be a hostname or an IP(v6) address. |
port | Port |
- Exceptions
-
◆ PosixProcess() [2/2]
PdCom::PosixProcess::PosixProcess |
( |
int |
fd | ) |
|
|
explicit |
Constructor.
- Parameters
-
fd | File descriptor, assumed to be connected, will be closed by dtor. |
◆ posixFlush()
void PdCom::PosixProcess::posixFlush |
( |
| ) |
|
|
protected |
◆ posixRead()
int PdCom::PosixProcess::posixRead |
( |
char * |
buf, |
|
|
int |
count |
|
) |
| |
|
protected |
◆ posixWriteBuffered()
void PdCom::PosixProcess::posixWriteBuffered |
( |
const char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
protected |
Buffered Wrapper for write().
This loops around write(), so no short writes can occur. It uses an internal buffer which can be flushed used posixFlush(). If the buffer is not big enough, it will be flushed and the content of buf
is written directly to the socket using posixWriteDirect().
If the socket works in nonblocking mode, it will be select()ed with a timeout set by setWriteTimeout() until everything is written.
- Parameters
-
buf | Buffer to send. |
count | Number of bytes to send. |
- Exceptions
-
- Examples:
- advanced_example.cpp, and sasl_example.cpp.
◆ posixWriteDirect()
void PdCom::PosixProcess::posixWriteDirect |
( |
const char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
protected |
Unbuffered Wrapper for write().
This loops around write(), so no short writes can occur. No internal buffer is used. If you used posixWriteBuffered() before, you'll have to flush() the internal buffer. Otherwise your data will be corrupted.
If the socket works in nonblocking mode, it will be select()ed with a timeout set by setWriteTimeout() until everything is written.
- Parameters
-
buf | Buffer to send. |
count | Number of bytes to send. |
- Exceptions
-
- Examples:
- gnutls_example.cpp.
◆ reconnect()
void PdCom::PosixProcess::reconnect |
( |
const char * |
host, |
|
|
unsigned short |
port |
|
) |
| |
|
protected |
Establish a new connection.
The internal buffer will be cleared, too.
- Parameters
-
host | Host, can be a hostname or an IP(v6) address. |
port | Port |
- Exceptions
-
◆ setWriteTimeout()
void PdCom::PosixProcess::setWriteTimeout |
( |
std::chrono::milliseconds |
ms | ) |
|
|
protected |
The documentation for this class was generated from the following file: