LogicGrowsOnTrees-1.0.0.0.1: a parallel implementation of logic programming using distributed tree exploration

Safe HaskellNone

LogicGrowsOnTrees.Utils.Handle

Contents

Description

This module contains a couple of utility functions for sending and receiving Serialize-able data over a handle. Because the size of the serialized value can depend on the value being sent, these functions employ a protocol in which first the size of the serialized data is sent as a 64-bit big-endian word, and then the serialized data itself is sent.

Synopsis

Exceptions

data ConnectionLost Source

This exception is thrown when the connection has been lost.

Constructors

ConnectionLost 

Functions

filterEOFExceptions :: IO a -> IO aSource

Replaces EOF IOExceptions with the ConnectionLost exception.

receive :: Serialize α => Handle -> IO αSource

Receives a Serialize-able value from a handle.

Specifically, this function reads in a 64-bit big-endian word with the size of the raw data to be read, reads that much data in bytes into a ByteString, and then deserializes the ByteString to produce the resulting value.

If the connection has been lost, it throws ConnectionLost.

send :: Serialize α => Handle -> α -> IO ()Source

Sends a Serialize-able value to a handle.

Specifically, this function serializes the given value to a ByteString, and then writes the size of the serialized data in bytes as a 64-bit big-endian word followed by the raw data itself.

If the connection has been lost, it throws ConnectionLost.