Last active
August 30, 2022 08:42
-
-
Save kenkangxgwe/30a65b5d172a6915d31e02cb7fe4d2ee to your computer and use it in GitHub Desktop.
ZeroMQLink Server read message issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require('node:net'); | |
const serverPort = 7570; | |
const host = "127.0.0.1"; | |
function connectServer() { | |
const client = net.connect(serverPort, host); | |
client.on('error', (err) => { | |
setTimeoutInterval(connectServer, 1000); | |
}); | |
return client; | |
} | |
const client = connectServer(); | |
client.write("test"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require('node:net'); | |
const serverPort = 7570; | |
function startCommunication(client) { | |
client.on('data', function (chunk) { | |
process.stdout.write(chunk); | |
}); | |
} | |
const server = net.createServer((connection) => { | |
startCommunication(connection); | |
}); | |
server.on('error', (err) => { | |
throw err; | |
}); | |
server.listen(serverPort); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server = SocketOpen[7570] | |
While[server["ConnectedClients"] === {}, Pause[0.1]] | |
server["ConnectedClients"] // Map[SocketReadMessage/*ByteArrayToString] | |
(* I know that the following works, but shouldn't SocketReadMessage also work before the socket is ever read? *) | |
(* SocketListen[7570, Echo[#Data]&] *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to show expected behavior:
Expected behavior
Terminal 1 shows
Steps to show actual behavior:
Actual behavior
Terminal 1 shows nothing