Using Streams: 1.3 Using Streams: The Basics: Writing Data to a Stream

Up: GEOS SDK TechDocs | Up | Prev: 1.2 Blocking on Read or Write | Next: 1.4 Reading Data from a Stream
StreamWrite(), StreamWriteByte()

To write data into a stream, call the routine StreamWrite() . This routine takes six arguments:

If all the data was written successfully, StreamWrite() will return zero and write the number of bytes written (i.e. the size of the data buffer passed) to the integer pointed to by the sixth argument. If it could not successfully write all the data, it will return one of the following StreamError values:

STREAM_WOULD_BLOCK
STREAM_NO_BLOCK had been passed, and there was no room to write any data to the stream. The sixth argument will be set to zero.
STREAM_SHORT_READ_WRITE
If STREAM_NOBLOCK had been passed, this means there was not enough room to write all the data. If STREAM_BLOCK had been passed, this means the stream was closed before all the data could be written. The sixth argument will contain the number of bytes actually written to the stream.
STREAM_CLOSING
The stream is in the process of being closed; no writing is permitted while this is happening. The sixth argument will be set to zero.
STREAM_CLOSED
The stream has already been closed. The sixth argument will be set to zero.

You may often want to write a single byte to the stream. There is a special routine to do this, StreamWriteByte() . This routine takes four arguments:

If the byte is written successfully, StreamWriteByte() will return zero. Otherwise, it will return one of the following error values:

STREAM_WOULD_BLOCK
STREAM_BLOCK had been passed, and there was no room to write any data to the stream.
STREAM_CLOSING
The stream is in the process of being closed; no writing is permitted while this is happening.
STREAM_CLOSED
The stream has already been closed.

Up: GEOS SDK TechDocs | Up | Prev: 1.2 Blocking on Read or Write | Next: 1.4 Reading Data from a Stream