Z-IO- Simple and high performance IO toolkit for Haskell
Copyright(c) Dong Han 2018
Safe HaskellNone



This module provides an API for creating IPC servers and clients. IPC Support is implemented with named pipes on Windows, and UNIX domain sockets on other operating systems.

On UNIX, the local domain is also known as the UNIX domain. The path is a filesystem path name. It gets truncated to sizeof(sockaddr_un.sun_path) - 1, which varies on different operating system between 91 and 107 bytes. The typical values are 107 on Linux and 103 on macOS. The path is subject to the same naming conventions and permissions checks as would be done on file creation. It will be visible in the filesystem, and will persist until unlinked.

On Windows, the local domain is implemented using a named pipe. The path must refer to an entry in \?pipe or \.pipe. Any characters are permitted, but the latter may do some processing of pipe names, such as resolving .. sequences. Despite appearances, the pipe name space is flat. Pipes will not persist, they are removed when the last reference to them is closed.


IPC Client

data IPCClientConfig Source #

A IPC client configuration




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.


Instances details
Show UVStream Source # 
Instance details

Defined in Z.IO.UV.UVStream

Output UVStream Source # 
Instance details

Defined in Z.IO.UV.UVStream


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

Input UVStream Source # 
Instance details

Defined in Z.IO.UV.UVStream


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

defaultIPCClientConfig :: IPCClientConfig Source #

Default config, connect to "./ipc".

initIPCClient :: IPCClientConfig -> Resource UVStream Source #

init a IPC client Resource, which open a new connect when used.

IPC Server

data IPCServerConfig Source #

A IPC server configuration




defaultIPCServerConfig :: IPCServerConfig Source #

A default hello world server on ./ipc

Test it with main = startIPCServer defaultIPCServerConfig

startIPCServer Source #


:: HasCallStack 
=> IPCServerConfig 
-> (UVStream -> IO ())

worker which get an accepted IPC stream, run in a seperated haskell thread, will be closed upon exception or worker finishes.

-> IO () 

Start a server

Fork new worker thread upon a new connection.

For test

helloWorld :: UVStream -> IO () Source #

Write "hello world" to a UVStream.

echo :: UVStream -> IO () Source #

Echo whatever received bytes.

Internal helper