【问题标题】:Working with Node IPC Namedpipe and Vb6 CallNamedPipe client使用 Node IPC Namedpipe 和 Vb6 CallNamedPipe 客户端
【发布时间】:2023-03-09 14:08:02
【问题描述】:

问题:节点 IPC 服务器没有从 vb 客户端读取任何数据。虽然我可以看到日志“客户端已连接”,但数据不会在任何时候触发,因此连接会立即结束并关闭。

我看到的输出:

VB 客户端代码:

    Dim strLen As Integer
    Dim rcvArray() As Byte, sndArray() As Byte, rcvStr As String
    Dim inBufBytes As Long, outBufBytes As Long, bytesRead As Long
    Dim i As Integer, Res As Long

    Dim sndStr As String
    sndStr = "Test Message"

    strLen = Len(sndStr)
    ReDim sndArray(5000)
    For i = 0 To strLen - 1
        sndArray(i) = Asc(Mid(sndStr, i + 1, 1))
    Next i

    ReDim rcvArray(5050)
    inBufBytes = 5000
    outBufBytes = 5050

    'Expecting Aero to send back an xml string with Bundles details
    Res = CallNamedPipe("\\.\pipe\MyPipe", sndArray(0), strLen,
                          rcvArray(0), outBufBytes,
                          bytesRead, 30000)
    'Wait up to 30 seconds for a response
    'Format the data received, and then display the data in the text box
    If Res > 0 Then
        rcvStr = StrConv(rcvArray, vbUnicode)
        TextBox2.Text = rcvStr
    End If

NodeJS 代码:

let net = require('net'),
    pipeName = '\\\\.\\pipe\\MyPipe',
    server = null;

server = net.createServer( (socket) => {
    console.log("-- Client Connected --\r\n");

    socket.on('data', (chunk) => {
        console.log(`Received ${chunk.length} bytes from ContainerPipe: ${chunk} \r\n`);
    });

    socket.on('end', () => {
        console.log("** End Client **\r\n");
    });

    socket.on('close', () => {
        console.log("** Close Client **\r\n");
    });

    socket.on('error', (err) => {
        console.log("** Error: %s \r\n", err.message);
    });
});

server.listen(pipeName, () => {
    console.log("\r\n== Server Listening ==\r\n");
});

【问题讨论】:

    标签: node.js vb6 ipc


    【解决方案1】:

    而不是使用

    CallNamedPipe
    

    我的解决方案是使用

    CreateFile
    WriteFile
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-07
      • 1970-01-01
      • 2010-09-23
      • 1970-01-01
      • 2023-01-24
      • 2012-01-25
      • 1970-01-01
      相关资源
      最近更新 更多