Z-IO-0.6.1.0: Simple and high performance IO toolkit for Haskell
Copyright(c) Dong Han 2017-2018
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Z.IO.UV.UVStream

Description

This module provides UVStream handle type.

Synopsis

uv_stream abstraction

initUVStream :: HasCallStack => (Ptr UVLoop -> Ptr UVHandle -> IO ()) -> UVManager -> Resource UVStream Source #

Safely lock an uv manager and perform uv_handle initialization.

Initialization an UV stream usually take two step:

  • allocate an uv_stream struct with proper size
  • lock a particular uv_loop from a uv manager, and perform custom initialization, such as uv_tcp_init.

And this is what initUVStream do, all you need to do is to provide the manager you want to hook the handle onto(usually the one on the same capability, i.e. the one obtained by getUVManager), and provide a custom initialization function (which should throw an exception if failed).

data UVStream Source #

A haskell data type wrap an uv_stream_t inside

UVStream DO NOT provide thread safety! Use UVStream concurrently in multiple threads will lead to undefined behavior.

Constructors

UVStream 

Instances

Instances details
Show UVStream Source # 
Instance details

Defined in Z.IO.UV.UVStream

Print UVStream Source # 
Instance details

Defined in Z.IO.UV.UVStream

Methods

toUTF8BuilderP :: Int -> UVStream -> Builder () #

Output UVStream Source # 
Instance details

Defined in Z.IO.UV.UVStream

Methods

writeOutput :: UVStream -> Ptr Word8 -> Int -> IO () Source #

Input UVStream Source # 
Instance details

Defined in Z.IO.UV.UVStream

Methods

readInput :: UVStream -> Ptr Word8 -> Int -> IO Int Source #

closeUVStream :: UVStream -> IO () Source #

Manually close a uv stream.

shutdownUVStream :: HasCallStack => UVStream -> IO () Source #

Shutdown the outgoing (write) side of a duplex stream. It waits for pending write requests to complete.

Futher writing will throw ResourceVanished(EPIPE).

helloWorld :: UVStream -> IO () Source #

Write "hello world" to a UVStream.

echo :: UVStream -> IO () Source #

Echo whatever received bytes.