tftp-0.2: A library for building tftp servers

Safe HaskellNone

Network.TFTP.Types

Description

Common types used internally. Re-exports the ByteString type to use as well as some monad transformer stuff, exceptions, logging, Word and printf.

Synopsis

Documentation

type ByteString = ByteStringSource

Alias for the Lazy ByteString that is used internally

pack :: [Word8] -> ByteString

O(n) Convert a '[Word8]' into a ByteString.

unpack :: ByteString -> [Word8]

O(n) Converts a ByteString to a '[Word8]'.

bdrop :: Int64 -> ByteString -> ByteStringSource

Candy for ByteString.pack to not interfere with Prelude(drop)

btake :: Int64 -> ByteString -> ByteStringSource

Candy for ByteString.take

blength :: ByteString -> Int64Source

Candy for ByteString.length

readFile :: FilePath -> IO ByteString

Read an entire file lazily into a ByteString. The Handle will be held open until EOF is encountered.

class (Eq address, Show address, Monad m, MonadIO m) => MessageIO m address | m -> address whereSource

Type class for monads that can send/receive messages

Methods

sendTo :: address -> ByteString -> m BoolSource

Send a message or return False when there was an error

receiveFrom :: Maybe Int -> m (Maybe (address, ByteString))Source

Receive a message, failing if no message was receive after a timeout (measured in seconds)

localAddress :: m addressSource

Return the address that receiveFrom receives on

Instances

MessageIO UDPIO Address

Abstraction over UDP IO for sending/receiving bytestrings

module Data.Word