Giter VIP home page Giter VIP logo

mirage-channel's Introduction

mirage-channel โ€” Buffered channels for MirageOS FLOW types

%%VERSION%%

Channels are buffered reader/writers built on top of unbuffered FLOW implementations.

Example:

module Channel = Channel.Make(Flow)
...
Channel.read_exactly ~len:16 t
>>= fun bufs -> (* read header of message *)
let payload_length = Cstruct.(LE.get_uint16 (concat bufs) 0) in
Channel.read_exactly ~len:payload_length t
>>= fun bufs -> (* payload of message *)

(* process message *)

Channel.write_buffer t header;
Channel.write_buffer t payload;
Channel.flush t
>>= fun () ->

mirage-channel is distributed under the ISC license.

Installation

mirage-channel can be installed with opam:

opam install channel

If you don't use opam consult the opam file for build instructions.

Documentation

The documentation and API reference is automatically generated by ocamldoc from the interfaces. It can be consulted online and there is a generated version in the doc directory of the distribution.

Sample programs

If you installed mirage-channel with opam sample programs are located in the directory opam config var channel:doc.

In the distribution sample programs and tests are located in the test directory of the distribution. They can be built with:

./build test

The resulting binaries are in _build/test.

  • test.native tests the library, nothing should fail.

mirage-channel's People

Contributors

samoht avatar avsm avatar hannesm avatar djs55 avatar yomimono avatar dinosaure avatar talex5 avatar craigfe avatar

Stargazers

Tim ats avatar Sora Morimoto avatar A ghost. avatar  avatar Seb Mondet avatar  avatar

Watchers

 avatar  avatar Amir Chaudhry avatar Richard Mortier avatar  avatar  avatar  avatar  avatar James Cloos avatar Magnus Skjegstad avatar collecting MirageOS relevant repositories (feed: see URL) avatar  avatar

mirage-channel's Issues

Type problem in the example

Hi,

Trying to run the example from a regular mirage built with unix sockets :

module Channel = Mirage_channel_lwt.Make(S.TCPV4)
...
let open Lwt_result.Infix in
let chan = Channel.create flow in
Channel.read_exactly ~len:16 chan
>>= fun bufs ->
let payload_length = Cstruct.(LE.get_uint16 (concat bufs) 0) in

I get an error on that last line :

Error: This expression has type Channel.buffer list Mirage_flow.or_eof
       but an expression was expected of type Cstruct.t list

I'm not sure if the example is out of date or if I'm just wrong on the Channel module, since that's not part of the example ? S being Mirage_stack_lwt.V4 passed from the main.

Channel.close with tls-mirage raises an End_of_file exception

This was originally filed under https://github.com/mirage/mirage-http/issues/28
The problem is with a Mirage unikernel running https under zen. Closing the connection give the following error:

Fatal error: exception (Failure "TLS.server_of_flow: End-of-file!")
Raised at file "format.ml", line 241, characters 41-52
Called from file "format.ml", line 482, characters 6-24
Mirage exiting with status 2
Do_exit called!

When mirage-http calls Channel.close, causes the Channel to flush, which writes to it's internal Flow. Digging further, it seems that by this point, when using tls_mirage, the Flow is already in a closed state, and raises an End_of_file exception. It looks like this bug came up a while ago here: mirage/mirage-net-xen#39 though I'm not sure what the resolution was. It seems like the decision was that the calling code should handle the exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.