FsNetMQ
NetMQ F# Binding
Install / Use
/learn @NetMQ/FsNetMQREADME
FsNetMQ
Example
use router = Socket.router ()
router.bind socket "tcp://*:6566"
use dealer = Socket.dealer ()
Socket.connect socket "tcp://127.0.0.1:6566"
Frame.send dealer "Hello"B
let frame,more = Frame.recv router
Poller
Poller is using IObservable, so when ever you add a socket to the poller you get an observable which you can subscribe to be notified of new messages.
use poller = Poller.create ()
use dealer = Socket.dealer ()
use subscriber = Socker.sub ()
// Connecting and subscribing...
let dealerObservable =
Poller.addSocket poller dealer
|> Observable.map Frame.recv
let subObservable =
Poller.addSocket poller subscriber
|> Observable.map Frame.recv
use observer =
Observable.merge dealerObservable subObservable
|> Observable.subscribe (fun msg -> printfn "%A" msg)
Poller.run poller
Actor
Actor is a thread with socket attached to it, so you are able to send it messages and request cancellation. Together with Poller it is a powerful concept.
// Actor is disposable, so whenever you call dispose on the actor the end message will be sent the thread will exit
let actor =
Actor.create (fun shim ->
use poller = Poller.create ()
// Registering for the end message which will cancel the actor
use emObserver = Poller.registerEndMessage poller shim
// Creating sockets and adding them to the poller
...
// Signalling that the actor is ready, this will let the Actor.create function to exit
Actor.signal shim
Poller.run poller
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
