There is no F# async wrapper (in the PowerPack) for neither
TcpListener.BeginAcceptTcpClient()
nor EndAcceptTcpClient()
.
How do I write my own wrapper around these, so that I can use the let!
and async
keywords and run it in parallel?
Have you checked out the Async.BuildPrimitive
function? I think you can do something like:
type TcpListener with
member x.AsyncAcceptClient() =
Async.BuildPrimitive(x.BeginAcceptTcpClient, x.EndAcceptTcpClient)
to create an extension method returning an appropriate async result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With