testUdp :: _ -> UV.Handler _ Unit testUdp loop = do recvH <- UV.udpNew loop UV.udpBind (UV.ip4Addr "0.0.0.0" 1234) [ UV._UdpReuseAddr ] recvH UV.udpRecvStart <@> recvH $ \(mBuf :: Maybe UV.Buffer) -> do mS <- traverse UV.bufferToString mBuf Console.log $ "udp: received: " <> show mS sendH <- UV.udpNew loop buf <- lift $ UV.bufferFromString "hello" UV.udpSend [ buf ] (UV.ip4Addr "0.0.0.0" 1234) (case _ of Right _ -> Console.log "udp: sent" Left errCode -> Console.log $ renderErrCode errCode ) sendH
The API is purposely low-level, and once complete could be wrapped up into something nice to use. Like a purescript-aff for PureC using libuvs async primitives.
The project lives here for now: https://github.com/pure-c/purec-uv. Don’t bother trying to compile and run it yet, though - I need to clean up a little first when I get around to it. Just wanted to post this here, gather feedback, and maybe find people interested in building this thing out.