Table of Contents
quanser.communications.stream.ignore
Receives data from a stream and discards it.
[bytes, would_block] = stream.ignore(num_bytes)
This function receives data over a client stream. However this data is simply discarded. It is not returned to the caller. It attempts to receive num_bytes bytes from the communication channel.
If
quanser.communications.stream.listen or
quanser.communications.stream.connect was called with the non-blocking flag set to false
(0), then
this function blocks until all the data is read. If the connection has been closed gracefully then it returns 0 only once there is no more
data to receive. Otherwise it returns the number of bytes read before the connection closed. Once all the data in the stream buffer is exhausted
it will return 0 to indicate the connection has been closed. If an error occurs, then it issues an error message.
If
quanser.communications.stream.listen or
quanser.communications.stream.connect was called with the non-blocking flag set to true
(1), then this
function does not block. If no data is available at all then it returns would_block equal to true
. In this case, the
poll function may be used with the 'receive' flag to determine when data becomes
available. Otherwise it returns the number of bytes received.
The semantics of this function differ from the BSD recv() socket function because it receives num_bytes bytes in blocking mode rather than the number of bytes that were sent in a single send() call at the peer. The semantics differ because this function attempts to "read ahead" by keeping the stream buffer full, thereby minimizing the number of receive operations performed on the internal connection. Also, due to buffering of the send methods, the number of send() calls made at the peer may not correspond to the number expected.
This operation is not valid on listening streams created using quanser.communications.stream.listen.
stream
Stream handle returned by quanser.communications.stream.connect or accept.
num_bytes
The number of bytes to ignore.
bytes
The number of bytes actually ignored.
would_block
Whether the function would have blocked. Always false for blocking streams.
bytes = stream.ignore(16); % Ignore 16 bytes
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.