Stream¶
Provides stream operations.
libuv reference: http://docs.libuv.org/en/v1.x/stream.html
Input Events¶
UV_STREAM_LISTEN¶
input (_uv_stream_t&&, int) UV_STREAM_LISTEN;
- Occurrence:
- Whenever a stream server receives an incoming connection.
- Payload:
_uv_stream_t&&
: pointer to the stream server
libuv reference: http://docs.libuv.org/en/v1.x/stream.html#c.uv_connection_cb
UV_STREAM_CONNECT¶
input (_uv_connect_t&&, int) UV_STREAM_CONNECT;
- Occurrence:
- Whenever a connection opens.
- Payload:
_uv_connect_t&&
: pointer to the connectionint
: open status0
: success<0
: error
libuv reference: http://docs.libuv.org/en/v1.x/stream.html#c.uv_connect_cb
UV_STREAM_READ¶
input (_uv_stream_t&&, ssize) UV_STREAM_READ;
- Occurrence:
- Whenever data is available on a stream.
- Payload:
_uv_stream_t&&
: pointer to the streamssize
: number of bytes available>0
: data available<0
: error
libuv reference: http://docs.libuv.org/en/v1.x/stream.html#c.uv_read_cb
UV_STREAM_WRITE¶
input (_uv_write_t&&, int) UV_STREAM_WRITE;
- Occurrence:
- Whenever writing to a stream completes.
- Payload:
_uv_write_T&&
: pointer to the write requestint
: completion status0
: success<0
: error
libuv reference: http://docs.libuv.org/en/v1.x/stream.html#c.uv_write_cb
UV_STREAM_ERROR¶
input (_uv_stream_t&&, int) UV_STREAM_ERROR;
- Occurrence:
- Whenever a read or write error occurs in a stream.
- Payload:
_uv_stream_t&&
: pointer to the streamint
: error code
UV_STREAM_ERROR
always occurs before the corresponding UV_STREAM_READ
or
UV_STREAM_WRITE
.
libuv reference: http://docs.libuv.org/en/v1.x/errors.html
Code Abstractions¶
UV_Stream_Listen¶
Starts listening for incoming connections in a stream.
code/await UV_Stream_Listen (var& _uv_stream_t stream, var int backlog)
-> (event& void ok)
-> int
- Parameters
stream
: stream to listenbacklog
: number of connections the kernel might queue
- Initialization
ok
: signalled on every new incoming connection
- Return
int
: operation status0
: success<0
: error
Céu-libuv references:
ceu_uv_listen
,
UV_STREAM_LISTEN
.
UV_Stream_Read¶
Reads bytes from a stream continuously.
code/await UV_Stream_Read (var& _uv_stream_t stream, vector&[] byte buf)
-> (event& usize ok)
-> int
- Parameters
stream
: stream to read frombuf
: destination buffer
- Initialization
ok
: signalled whenever new data is read to the destination buffer
- Return
int
: read error- returns only in case of error (always
<0
)
- returns only in case of error (always
Céu-libuv references:
ceu_uv_read_start
,
UV_STREAM_READ
.
libuv references:
uv_read_stop
.
Note: all allocated libuv resources are automatically released on termination.
UV_Stream_ReadLine¶
Reads a single line from a stream.
code/await UV_Stream_ReadLine (var& _uv_stream_t stream, vector&[] byte string)
-> void
- Parameters
stream
: stream to read fromstring
: destination string buffer
- Return
void
: nothing
Céu-libuv references:
UV_Stream_Read
.
UV_Stream_Write¶
Write bytes to a stream.
code/await UV_Stream_Write (var& _uv_stream_t stream, vector&[] byte buf)
-> int
- Parameters
stream
: stream to write tobuf
: source buffer
- Return
int
: operation status0
: success<0
: error
Céu-libuv references:
ceu_uv_write
,
UV_STREAM_WRITE
.
Note: all allocated libuv resources are automatically released on termination.