PdCom  5.0
Process data communication client
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PdCom::PosixProcess Class Reference

Wrapper around POSIX socket. More...

#include <PosixProcess.h>

Classes

struct  ConnectionFailed
 
struct  ReadFailure
 
struct  WriteFailure
 

Public Member Functions

 PosixProcess (const char *host, unsigned short port)
 Constructor. More...
 
 PosixProcess (PosixProcess &&o) noexcept
 
PosixProcessoperator= (PosixProcess &&o) noexcept
 

Protected Member Functions

void posixWrite (const char *buf, size_t count)
 Wrapper for write(). More...
 
size_t posixRead (char *buf, size_t count)
 Wrapper for read(). More...
 

Protected Attributes

int fd_
 

Detailed Description

Wrapper around POSIX socket.

You can derive from this class to use POSIX socket with your Process instance.

Examples:
advanced_example.cpp.

Constructor & Destructor Documentation

◆ PosixProcess()

PdCom::PosixProcess::PosixProcess ( const char *  host,
unsigned short  port 
)

Constructor.

Parameters
hostHost, can be a hostname or an IP(v6) address.
portPort
Exceptions
ConnectionFailedConnection could not be established.

Member Function Documentation

◆ posixRead()

size_t PdCom::PosixProcess::posixRead ( char *  buf,
size_t  count 
)
protected

Wrapper for read().

Parameters
bufBuffer to read into.
countSize of the buffer in bytes.
Returns
Number of bytes read.
Exceptions
ReadFailureread() from socket fails.
Examples:
advanced_example.cpp.

◆ posixWrite()

void PdCom::PosixProcess::posixWrite ( const char *  buf,
size_t  count 
)
protected

Wrapper for write().

This loops around write(), so no short writes can occur.

Parameters
bufBuffer to send.
countNumber of bytes to send.
Exceptions
WriteFailurewrite() to socket fails.
Examples:
advanced_example.cpp.

The documentation for this class was generated from the following file: