Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cMailslotReader Class Reference

#include <cMailslot.h>

Inheritance diagram for GrayLib::cMailslotReader:
GrayLib::cMailslot Gray::cStreamInput Gray::cStreamBase

Public Member Functions

 cMailslotReader ()
 
virtual ~cMailslotReader ()
 
virtual HRESULT Connect (const FILECHAR_t *pszSlotname, const FILECHAR_t *szServer=nullptr, _SECURITY_ATTRIBUTES *pSa=nullptr) override
 
virtual HRESULT ReadX (void *pbData, size_t nLengthMax) override
 
HRESULT ReadX (cHeapBlock &buffer, size_t nReasonableLengthMax=0x1000)
 
UINT GetMessageCount (size_t *pnNextMessageLength=nullptr)
 
bool put_ReadTimeout (TIMESYSD_t nReadTimeout)
 
- Public Member Functions inherited from GrayLib::cMailslot
virtual void Disconnect ()
 
cStringF get_MailslotPath () const
 
bool isOpen () const
 
 UNITTEST2_PREDEF (cMailslot)
 
- Public Member Functions inherited from Gray::cStreamInput
 cStreamInput () noexcept
 
virtual ~cStreamInput ()
 
virtual size_t SetSeekSizeMin (size_t nSizeMin=k_FILE_BLOCK_SIZE)
 
virtual HRESULT ReadX (OUT void *pData, size_t nDataSize)
 
HRESULT ReadAll (OUT cHeapBlock &block, size_t nSizeExtra=0)
 
virtual HRESULT ReadStringLine (OUT char *pszBuffer, StrLen_t iSizeMax)
 
virtual HRESULT ReadStringLine (OUT wchar_t *pszBuffer, StrLen_t iSizeMax)
 
HRESULT ReadT (OUT void *pVal, size_t nSize)
 
template<typename TYPE >
HRESULT ReadT (OUT TYPE &val)
 
template<typename TYPE >
HRESULT ReadTN (OUT TYPE &val)
 
HRESULT ReadSize (OUT size_t &nSize)
 
template<typename TYPE >
HRESULT ReadSizeT (OUT TYPE &n)
 
HRESULT ReadHashCode (OUT UINT32 &nHashCode)
 
HRESULT ReadHashCode (OUT UINT64 &nHashCode)
 
HRESULT ReadN (OUT BYTE *pBuffer, size_t nSizeMax)
 
template<typename _CH >
HRESULT ReadStringN (OUT _CH *pszStr, StrLen_t iSizeMax)
 
virtual HRESULT ReadPeek (void *pData, size_t nDataSize)
 
- Public Member Functions inherited from Gray::cStreamBase
virtual ~cStreamBase ()
 
virtual STREAM_SEEKRET_t Seek (STREAM_OFFSET_t iOffset, SEEK_ORIGIN_TYPE eSeekOrigin=SEEK_Set)
 
void SeekToBegin ()
 
STREAM_POS_t SeekToEnd ()
 
virtual STREAM_POS_t GetPosition () const
 
virtual STREAM_POS_t GetLength () const
 

Public Attributes

size_t m_nMaxMessageSize
 0 = any size More...
 
TIMESYSD_t m_nReadTimeout
 cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER More...
 

Additional Inherited Members

- Static Public Attributes inherited from GrayLib::cMailslot
static const FILECHAR_tk_pszServerDefault = _FN(".")
 
- Static Public Attributes inherited from Gray::cStreamBase
static const BYTE k_SIZE_MASK = 0x80
 Used for WriteSize() More...
 
static const size_t k_FILE_BLOCK_SIZE = (32 * 1024)
 default arbitrary transfer block size. more than this is NOT more efficient. More...
 
- Protected Member Functions inherited from GrayLib::cMailslot
 cMailslot ()
 
virtual ~cMailslot ()
 
- Static Protected Member Functions inherited from GrayLib::cMailslot
static StrLen_t GRAYCALL MakeMailslotPath (OUT FILECHAR_t *pszPath, const FILECHAR_t *pszSlotName, const FILECHAR_t *pszServerName=nullptr)
 
static cStringF GRAYCALL MakeMailslotPath (const FILECHAR_t *pszSlotName, const FILECHAR_t *pszServerName=nullptr)
 
- Protected Attributes inherited from GrayLib::cMailslot
cStringF m_sMailslotPath
 "\\\\%s\\mailslot\\%s" More...
 
mqd_t m_q
 init to -1 More...
 

Detailed Description

can be just 1 server/reader Mail slot reader class. Used to read from a mail slot.

Constructor & Destructor Documentation

◆ cMailslotReader()

GrayLib::cMailslotReader::cMailslotReader ( )

only one reader (server) is allowed . many writers (clients) are allowed.

◆ ~cMailslotReader()

GrayLib::cMailslotReader::~cMailslotReader ( )
virtual

Member Function Documentation

◆ Connect()

HRESULT GrayLib::cMailslotReader::Connect ( const FILECHAR_t pszSlotname,
const FILECHAR_t szServer = nullptr,
_SECURITY_ATTRIBUTES *  pSa = nullptr 
)
overridevirtual

Create a named mail slot. This must be done on the local machine thus we don't use the server name parameter. can be opened only once by one owner.

Implements GrayLib::cMailslot.

◆ GetMessageCount()

UINT GrayLib::cMailslotReader::GetMessageCount ( size_t *  pnNextMessageLength = nullptr)
Returns
a count of how many messages are waiting in the mailslot. also the size of the next message in pnNextSize.

◆ put_ReadTimeout()

bool GrayLib::cMailslotReader::put_ReadTimeout ( TIMESYSD_t  nReadTimeout)

change the read timeout.

  • dwReadTimeout = mSec

◆ ReadX() [1/2]

HRESULT GrayLib::cMailslotReader::ReadX ( cHeapBlock buffer,
size_t  nReasonableLengthMax = 0x1000 
)

Read a message from the mailslot and return it in a buffer allocated we have no idea how much data is coming...

Returns
ERROR_SEM_TIMEOUT = nothing read in time.

◆ ReadX() [2/2]

HRESULT GrayLib::cMailslotReader::ReadX ( void *  pbData,
size_t  nLengthMax 
)
overridevirtual

cStreamInput

Returns
ERROR_SEM_TIMEOUT = nothing read in time.

Member Data Documentation

◆ m_nMaxMessageSize

size_t GrayLib::cMailslotReader::m_nMaxMessageSize

0 = any size

◆ m_nReadTimeout

TIMESYSD_t GrayLib::cMailslotReader::m_nReadTimeout

cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER


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