spio_t_error_code user_close( void **puser_data, spio_t_bits close_options );
This is the prototype for one of the methods of user defined streams. It is used when SICStus wants to close one or both directions of a user defined stream.
A pointer to the same value as was passed to
On successful return, if the stream has been closed and any resources
*puser_data should be set to
user_close fails, it can still set
NULL to signify that the stream is no longer usable.
The following bits can be set:
The read direction should be closed. Only set if the device was created as an input or bidirectional device.
The write direction should be closed. Only set if the device was created as an output or bidirectional device.
The specified directions should be closed without attempting to flush
any data. Among other things this option may be passed if a previous
user_close returned an error.
Note that a bidirectional stream should only close the directions
specified by the
close_options. Also note that
user_close for a bidirectional stream may be called several
times and that the same direction flag, e.g.
SPIO_DEVICE_CLOSE_OPTION_READ may be specified more than once,
even if that direction has already been closed successfully.
Once a call to
user_close has set
NULL, none of the device methods will be called
again. Note that a
*puser_data may be set to
when a failure code is returned. This is useful if the failure is
There is no option to specify non-blocking close, it is expected that
user_close will finish quickly. To make this more likely,
user_flush_output is called before non-forcibly closing an
On success, return
SPIO_S_NOERR or some other success code and
*puser_data if and only if the user data and any other
resources have been freed.
On failure, return a SPIO error code. Error codes with special meaning
Returned if there were buffered data and it is not possible to write more data onto the stream, e.g. some underlying device has been closed.
Other error codes may also be returned.
Should close one or all directions depending on the
close_options. If all directions have been closed, the user
data should be deallocated and
*puser_data set to
cpg-ref-SP_create_stream. Defining a New Stream.