![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cNetStream.h>
Public Member Functions | |
cNetStream (SOCKET hSocket=INVALID_SOCKET, bool bAsync=false, size_t nRxBufferLimit=(cStream::k_FILE_BLOCK_SIZE/2)) | |
virtual | ~cNetStream (void) |
bool | isConnected () const |
bool | isConnecting () const noexcept |
bool | isValidSocket () const noexcept |
HASHCODE_t | get_HashCode () const noexcept |
bool | isInputDesired () const |
bool | isInputEmpty () const |
bool | isOutputEmpty () const |
ITERATE_t | get_InputQty () const |
ITERATE_t | get_OutputQty () const |
virtual HRESULT | onEventWrite () |
override these if we want to know if data is ready to TX or RX More... | |
virtual HRESULT | onEventRead () |
FD_WRITE similar to MFC OnReceive. More... | |
HRESULT | UpdateQWrite () |
HRESULT | UpdateQRead () |
cStreamOutput * | get_StreamOut () |
cStreamInput * | get_StreamInp () |
virtual HRESULT | WriteX (const void *pData, size_t nDataSize) override |
virtual HRESULT | ReadX (void *pData, size_t nDataSize) override |
virtual size_t | SetSeekSizeMin (size_t nSizeMin=k_FILE_BLOCK_SIZE) override |
virtual STREAM_SEEKRET_t | Seek (STREAM_OFFSET_t iOffset, SEEK_ORIGIN_TYPE eSeekOrigin) override |
Disambiguate Seek for cStreamBase to cStreamInput for stupid compiler. More... | |
virtual void | Close () |
void | SetStateEstablished () |
UNITTEST_FRIEND (cNetStream) | |
![]() | |
virtual STREAM_POS_t | GetPosition () const override |
virtual STREAM_POS_t | GetLength () const override |
void | SeekToBegin () |
STREAM_POS_t | SeekToEnd () |
![]() | |
cStreamInput () noexcept | |
virtual | ~cStreamInput () |
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) |
![]() | |
virtual | ~cStreamBase () |
void | SeekToBegin () |
STREAM_POS_t | SeekToEnd () |
![]() | |
cStreamOutput () noexcept | |
virtual | ~cStreamOutput () |
HRESULT | WriteT (const void *pVal, size_t nDataSize) |
template<typename TYPE > | |
HRESULT | WriteT (TYPE val) |
HRESULT | WriteSize (size_t nSize) |
HRESULT | WriteHashCode (HASHCODE_t nHashCode) |
HRESULT | WriteN (const void *pBuffer, size_t nSize) |
template<typename _CH > | |
HRESULT | WriteStringN (const _CH *pszStr) |
template<typename _CH > | |
HRESULT | WriteCharRepeat (_CH nChar, int nCount=1) |
virtual HRESULT | WriteString (const char *pszStr) |
virtual HRESULT | WriteString (const wchar_t *pszStr) |
StrLen_t | VPrintf (const char *pszFormat, va_list args) |
StrLen_t | VPrintf (const wchar_t *pszFormat, va_list args) |
StrLen_t _cdecl | Printf (const char *pszFormat,...) |
StrLen_t _cdecl | Printf (const wchar_t *pszFormat,...) |
HRESULT | WriteStream (cStreamInput &sInp, STREAM_POS_t nSizeMax=k_FILE_BLOCK_SIZE, IStreamProgressCallback *pProgress=nullptr, TIMESYSD_t nTimeout=0) |
Copy cStreamInput to this stream. More... | |
virtual HRESULT | FlushX () |
![]() | |
void | Add (const cStreamStats &n) |
Public Attributes | |
cNetSocket | m_Socket |
the raw TCP SOCKET we are buffering to/from. More... | |
bool | m_bAsync |
Will this socket be using OnEvent FD_READ FD_WRITE events ? More... | |
bool | m_bInpThrottled |
The m_bAsync input was throttled. we cant rely on m_bAsync OnEvent to notify us again. we must poll. More... | |
cStreamQueue | m_bout |
raw output buffer to m_Socket. can write to this externally if m_bAsync. More... | |
cStreamQueue | m_binp |
raw input buffer from m_Socket. can read from this externally if m_bAsync. More... | |
HRESULT | m_hResultRx |
The status of the connect or disconnect. S_OK = connected. else how to it close ? don't return this until we read all the m_binp data. More... | |
![]() | |
cStreamStat | m_StatOut |
cStreamStat | m_StatInp |
Additional Inherited Members | |
![]() | |
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... | |
This is wrapper for cNetSocket with extra level of buffering (usually for TCP). both input and output buffered streams. (arbitrary buffer size) We can use Seek() to back up the read queue. (if we didn't get(RX) enough data to fill an atomic transaction)
GrayLib::cNetStream::cNetStream | ( | SOCKET | hSocket = INVALID_SOCKET , |
bool | bAsync = false , |
||
size_t | nRxBufferLimit = (cStream::k_FILE_BLOCK_SIZE / 2) |
||
) |
|
virtual |
|
virtual |
cStream. Force a close.
Reimplemented in GrayLib::cNetServerConnection.
|
inlinenoexcept |
Use the socket id as a unique id for this stream.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Actually connected (or connecting) to a peer.
|
inlinenoexcept |
connecting to a peer.
|
inline |
Is this a write only socket? No input buffer size = write only.
|
inline |
no data to read?
|
inline |
no data to write?
|
inlinenoexcept |
socket handle is valid.
|
virtual |
FD_WRITE similar to MFC OnReceive.
Event FD_READ or polled frequently. Read and queue up any data that is available.
Reimplemented in GrayLib::cNetServerConnection.
|
virtual |
override these if we want to know if data is ready to TX or RX
FD_READ similar to MFC OnSend
use event FD_WRITE if possible. else someone needs to poll this Check if TX is ready/needed?
|
overridevirtual |
Read from cStream Read incoming data from the stream from socket. fill stream buffer from socket if needed.
|
overridevirtual |
Disambiguate Seek for cStreamBase to cStreamInput for stupid compiler.
Seek to some read position in the stored data.
Reimplemented from Gray::cStream.
|
overridevirtual |
There are no incomplete transactions read.
Reimplemented from Gray::cStreamInput.
|
inline |
A successful blocking outgoing connection indicates we are ready to RX. FD_CONNECT.
GrayLib::cNetStream::UNITTEST_FRIEND | ( | cNetStream | ) |
HRESULT GrayLib::cNetStream::UpdateQRead | ( | ) |
HRESULT GrayLib::cNetStream::UpdateQWrite | ( | ) |
|
overridevirtual |
Write to cStream
Reimplemented from Gray::cStreamOutput.
bool GrayLib::cNetStream::m_bAsync |
Will this socket be using OnEvent FD_READ FD_WRITE events ?
cStreamQueue GrayLib::cNetStream::m_binp |
raw input buffer from m_Socket. can read from this externally if m_bAsync.
bool GrayLib::cNetStream::m_bInpThrottled |
The m_bAsync input was throttled. we cant rely on m_bAsync OnEvent to notify us again. we must poll.
cStreamQueue GrayLib::cNetStream::m_bout |
raw output buffer to m_Socket. can write to this externally if m_bAsync.
HRESULT GrayLib::cNetStream::m_hResultRx |
The status of the connect or disconnect. S_OK = connected. else how to it close ? don't return this until we read all the m_binp data.
cNetSocket GrayLib::cNetStream::m_Socket |
the raw TCP SOCKET we are buffering to/from.