Important: The information in this document is obsolete and should not be used for new development.
OTCountDataBytes
Returns the amount of data currently available to be read.C INTERFACE
OTResult OTCountDataBytes(EndpointRef ref, size_t* countPtr);C++ INTERFACE
OTResult TEndpoint::CountDataBytes(size_t* countPtr);PARAMETERS
ref
- The endpoint reference of the endpoint whose pending data you wish to count.
countPtr
- A pointer to a value that is set to the size (in bytes) of the data in the first packet waiting to be read from the endpoint.
- function result
- See Appendix B.
DISCUSSION
If the function returns successfully, thecountPtr
parameter points to a buffer containing an approximation of the the number of bytes in the message buffer at the top of the stream.What the function counts depends on the type of endpoint. If it is packet-oriented, the function counts the number of bytes in the first packet. If it's stream-oriented and if nonexpedited data was received in more than one piece, the function provides a count of the sum of the pieces, but if expedited data was received in multiple parts, the function only provides a count of the data in the first part.
You can call this function upon receipt of a
T_DATA
event to get an approximation of find out how much data is currently available and to determine whether you need to allocate larger buffers before calling a function that reads the data. But, you should be careful not to assume that this is all the data. You should always read data until you get thekOTNoDataErr
result.Because what this function counts depends on which event is the most current outstanding event and because other events can occur before the function can complete, never use this count as more than a hint.