首页 > 解决方案 > Haskell SendFile 零拷贝 - 中止传输

问题描述

您好我想在 Haskell 中使用以下库在节点之间传输文件:https ://hackage.haskell.org/package/sendfile-0.7.11.1/docs/Network-Socket-SendFile.html

sendFile如果文件已被另一个节点传输,我希望能够中止......

我正在考虑使用 iteratee 来做这个例子:

runIter :: IO Iter -> IO ()
runIter iter =
   do r <- iter
      case r of
        (Done _n)      -> return ()
        (Sent _n cont) -> runIter cont
        (WouldBlock _n fd cont) -> 
            do threadWaitWrite fd
               runIter cont

我的问题是:我怎样才能中止这个转移?

我正在考虑做这样的事情:

(Sent _n cont) -> return () 或者 (Sent _n cont) -> error "Already downloaded (Abort)"

基本上有办法让客户知道呼叫已中止......

库中没有任何解释来实现这种行为......

标签: haskellsendfilezero-copy

解决方案


推荐阅读