Safe Haskell | None |
---|
Transmission of data via TFTP. This implements the stop-and-wait style data transmission protocol.
- type XFerT m address a = StateT (XFerState address) m a
- runTFTP :: MessageIO m address => XFerT m address result -> m result
- offerSingleFile :: MessageIO m address => Maybe Int -> String -> ByteString -> XFerT m address Bool
- writeData :: MessageIO m address => ByteString -> XFerT m address Bool
- continueAfterACK :: MessageIO m address => StateT (XFerState address) m b -> StateT (XFerState address) m b -> StateT (XFerState address) m b -> StateT (XFerState address) m b
- maxRetries :: Int
- ackTimeOut :: Maybe Int
- data XFerState address = XFerState {
- xsBlockIndex :: Word16
- xsFrom :: Maybe address
- resetBlockIndex :: Monad m => XFerT m address ()
- getBlockIndex :: Monad m => XFerT m address Word16
- incBlockIndex :: Monad m => XFerT m address Word16
- getLastPeer :: Monad m => XFerT m address (Maybe address)
- setLastPeer :: MessageIO m address => Maybe address -> XFerT m address ()
- replyData :: MessageIO m address => ByteString -> XFerT m address ()
- reply :: MessageIO m address => Message -> XFerT m address ()
- send :: MessageIO m address => address -> Message -> XFerT m address ()
- receive :: MessageIO m address => Maybe Int -> XFerT m address (Maybe Message)
- printInfo :: MessageIO m address => String -> XFerT m address ()
- printWarn :: MessageIO m address => String -> XFerT m address ()
- printErr :: MessageIO m address => String -> XFerT m address ()
- logWith :: MessageIO m address => (String -> String -> IO ()) -> String -> XFerT m address ()
Documentation
type XFerT m address a = StateT (XFerState address) m aSource
XFer monad parameterised over a (MessageIO) monad.
runTFTP :: MessageIO m address => XFerT m address result -> m resultSource
Execute a transfer action.
offerSingleFile :: MessageIO m address => Maybe Int -> String -> ByteString -> XFerT m address BoolSource
A simple server action that will wait for a RRQ for its file.
writeData :: MessageIO m address => ByteString -> XFerT m address BoolSource
A transfer action that sends a large chunk of data via TFTP DATA messages to a destination.
continueAfterACK :: MessageIO m address => StateT (XFerState address) m b -> StateT (XFerState address) m b -> StateT (XFerState address) m b -> StateT (XFerState address) m bSource
Receive the next message from the client, if the client anserws with the
correct ack call success
. If there was a timeout or the ack was for an
invalid index call retry
, if an error occured call 'error
The default number of re-transmits during writeData
The default time continueAfterACK
waits for an ACK.
Internal state record for a transfer
XFerState | |
|
resetBlockIndex :: Monad m => XFerT m address ()Source
Reset the current block index for an ongoing transfer to 0
getBlockIndex :: Monad m => XFerT m address Word16Source
Read the current block index for an ongoing transfer
incBlockIndex :: Monad m => XFerT m address Word16Source
Increment the current block index for an ongoing transfer
getLastPeer :: Monad m => XFerT m address (Maybe address)Source
Return the origin(Address
) of the message last received, or Nothing
setLastPeer :: MessageIO m address => Maybe address -> XFerT m address ()Source
Overwrite the origin(Address
) of the message last received
replyData :: MessageIO m address => ByteString -> XFerT m address ()Source
Send a DATA
packet to the origin(Address
) of the message last received with the current block index
reply :: MessageIO m address => Message -> XFerT m address ()Source
Send any Message
to the address to where the last message received from
send :: MessageIO m address => address -> Message -> XFerT m address ()Source
Send any Message
to an Address