nanomsg-haskell alternatives and similar packages
Based on the "Networking" category.
Alternatively, view nanomsg-haskell alternatives based on common mentions on social networks and blogs.
-
call-haskell-from-anything
Call Haskell functions from any programming language via serialization and dynamic libraries -
PortFusion
Haskell-powered cross-platform transport-layer distributed reverse / forward proxy & tunneling solution – currently available for all TCP protocols (RDP, VNC, HTTP(S), SSH, ...). -
ngx-export
A comprehensive web framework aimed at building custom Haskell handlers for the Nginx Web Server
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of nanomsg-haskell or a related project?
README
nanomsg-haskell
This is a Haskell binding for the nanomsg library: http://nanomsg.org/.
There's support for (evented) blocking send and recv, a non-blocking receive, and for all the socket types and the functions you need to wire them up and tear them down again.
Most socket options are available through accessor and mutator functions. Sockets are typed, transports are not.
Building
You would normally make sure the nanomsg library is on your system and then install from Hackage, but can build from source following these steps:
- Build and install nanomsg (and zeromq, if you are building benchmarks)
- git clone https://github.com/ivarnymoen/nanomsg-haskell
- cd nanomsg-haskell && cabal sandbox init
- cabal install --dependencies-only [--enable-tests] [--enable-benchmarks]
- cabal configure [--enable-tests] [--enable-benchmarks]
- cabal build
- [cabal test]
Usage
Simple pub/sub example:
Server:
module Main where
import Nanomsg
import qualified Data.ByteString.Char8 as C
import Control.Monad (mapM_)
import Control.Concurrent (threadDelay)
main :: IO ()
main =
withSocket Pub $ \s -> do
_ <- bind s "tcp://*:5560"
mapM_ (\num -> sendNumber s num) (cycle [1..1000000 :: Int])
where
sendNumber s number = do
threadDelay 1000 -- let's conserve some cycles
let numAsString = show number
send s (C.pack numAsString)
Client:
module Main where
import Nanomsg
import qualified Data.ByteString.Char8 as C
import Control.Monad (forever)
main :: IO ()
main =
withSocket Sub $ \s -> do
_ <- connect s "tcp://localhost:5560"
subscribe s $ C.pack ""
forever $ do
msg <- recv s
C.putStrLn msg
Nonblocking client:
module Main where
import Nanomsg
import qualified Data.ByteString.Char8 as C
import Control.Monad (forever)
import Control.Concurrent (threadDelay)
main :: IO ()
main =
withSocket Sub $ \s -> do
_ <- connect s "tcp://localhost:5560"
subscribe s $ C.pack ""
forever $ do
threadDelay 700 -- let's conserve some cycles
msg <- recv' s
C.putStrLn $ case msg of
Nothing -> C.pack "No message"
Just m -> m