-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZeroMQClient.js
More file actions
25 lines (21 loc) · 893 Bytes
/
ZeroMQClient.js
File metadata and controls
25 lines (21 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const zmq = require('zeromq');
// ZeroMQ Request Socket erstellen
const socket = new zmq.Request();
(async () => {
try {
console.log('Connecting to ZeroMQ server...');
// Verbinde mit dem ZeroMQ-Server auf Port 33406
await socket.connect('tcp://localhost:33406');
console.log('Connected to ZeroMQ server on port 33406');
// Sende eine Testnachricht an den ZeroMQ-Server
console.log('Sending message...');
await socket.send(JSON.stringify({ type: 'test', message: 'Hello from ZeroMQ Client' }));
// Auf Antwort vom ZeroMQ-Server warten
const [reply] = await socket.receive();
console.log('Received reply:', reply.toString());
} catch (error) {
console.error('Error communicating with ZeroMQ server:', error.message);
} finally {
socket.close();
}
})();