Comments (1)
In Windows 11 with the new 26 pyzmq version ipc seems to work. So this can be closed propably?
import zmq
import os
import numpy as np
import logging
from multiprocessing import Process
# Configure logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
# Create a random numpy array of 1MB
array_size = 1 * 1024 * 1024 // 8 # 1MB of float64
random_array = np.random.rand(array_size)
# Save the array to a file
filename = 'random_array.npy'
np.save(filename, random_array)
logging.debug(f'Saved random array to {filename}')
# Define the IPC endpoint
ipc_endpoint = 'ipc://test_ipc.ipc'
def server():
logging.debug('Server: Starting...')
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind(ipc_endpoint)
logging.debug(f'Server: Bound to {ipc_endpoint}')
message = socket.recv()
logging.debug('Server: Received message')
# Save the received message to a numpy file
received_array = np.frombuffer(message, dtype=np.float64)
np.save('received_array.npy', received_array)
logging.debug('Server: Saved received array to received_array.npy')
# Load the original array from file
original_array = np.load(filename)
logging.debug('Server: Loaded original array from file')
# Load the received array from file
loaded_received_array = np.load('received_array.npy')
logging.debug('Server: Loaded received array from file')
# Compare the arrays
if np.array_equal(loaded_received_array, original_array):
socket.send_string("SUCCESS")
logging.info("SUCCESS for IPC")
logging.debug('Server: Arrays match. Sent SUCCESS to client')
else:
socket.send_string("FAILURE")
logging.debug('Server: Arrays do not match. Sent FAILURE to client')
def client():
logging.debug('Client: Starting...')
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect(ipc_endpoint)
logging.debug(f'Client: Connected to {ipc_endpoint}')
# Load the original array from file
original_array = np.load(filename)
logging.debug('Client: Loaded original array from file')
# Send the array as bytes
socket.send(original_array.tobytes())
logging.debug('Client: Sent data to server')
result = socket.recv_string()
logging.debug(f'Client: Received result from server: {result}')
return result
if __name__ == '__main__':
logging.debug('Main: Starting server and client processes')
server_process = Process(target=server)
server_process.start()
logging.debug('Main: Server process started')
client_process = Process(target=client)
client_process.start()
logging.debug('Main: Client process started')
client_process.join()
server_process.join()
logging.debug('Main: Server and client processes joined')
# Clean up the generated files
os.remove(filename)
os.remove('received_array.npy')
logging.debug('Main: Cleaned up generated files')
from libzmq.
Related Issues (20)
- ZMQ subscriber doesn't receive message first time occasionally. HOT 2
- BUG: IPC socket drops messages, ignores LINGER HOT 1
- What is the procedure to finalise a DRAFT API feature HOT 1
- How can I clear the internal buffer of ZMQ multicast without closing the socket?
- Add more guidance on error handling in the guide/docs
- Too many resets on loopback after socket.connect() call HOT 1
- cmake: ZMQ_WIN32_WINNT autodetection broken when cross-compiling with mingw-w64
- When the topic length of sub exceeds 15kb, xpub crashes when calling zmq_msg_recv.
- High latency when messages are not being send repeatedly HOT 4
- Latest libsodium has deprecated functions, causing it not to compile HOT 1
- tools: curve_keygen not built when building with cmake, ninja HOT 2
- Curve not working on ZeroMQ on IoS HOT 1
- test_busy_poll.cpp missing from zeromq 4.3.5 tarball
- Large stacks in ZeroMQ threads lead to inflated crashpad minidumps on Windows
- build fail on Ubuntu 24.04 LTS: autogen.sh stopped with error HOT 1
- Why am I no longer on the contributor list? HOT 2
- Bad file descriptor while retrieving peer address HOT 1
- How to compile the libzmq library with ipv6 protocol in openEuler? HOT 1
- Consumer threads can never be awakened use ypipe_t
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libzmq.