Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 47ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
z

zmq

Recently created Least recently created Recently updated Least recently updated

timmy / 使用 zmq 進行跨進程或分散式訊息傳遞

Last active 5 hours ago distributed-systems ipc messaging networking python zmq

zmq(ZeroMQ)是一個高效能的訊息佇列庫,可用於進程間通訊(IPC)、分散式系統與即時訊息傳輸,適用於微服務架構、物聯網(IoT)和高效能計算應用。

0 0 0 2
1 import zmq
2
3 # 設置 ZeroMQ 上下文
4 context = zmq.Context()
5 socket = context.socket(zmq.REP) # 設定為回應 (REP) 模式
6 socket.bind("tcp://*:5555") # 監聽 5555 埠口
7
8 print("伺服器啟動,等待客戶端請求...")
9
10 while True: