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 connection
    • int: open status
      • 0: 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 stream
    • ssize: 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 request
    • int: completion status
      • 0: 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 stream
    • int: 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 listen
    • backlog: number of connections the kernel might queue
  • Initialization
    • ok: signalled on every new incoming connection
  • Return
    • int: operation status
      • 0: 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 from
    • buf: 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)

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 from
    • string: 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 to
    • buf: source buffer
  • Return
    • int: operation status
      • 0: success
      • <0: error

Céu-libuv references: ceu_uv_write, UV_STREAM_WRITE.

Note: all allocated libuv resources are automatically released on termination.