How does nodejs send a binary structure over socket? The receiver is a c program

net: is intended to be used in nodejs

var net = require("net");

send such a structure to the peer:

typedef struct msg_head{
    unsigned int type;
    unsigned int len;
    int state;
}msg_head;

how should the data sent be organized?

Mar.18,2021

it is recommended that you first determine with the receiver their system architecture (32-bit / 64-bit), the compiler they use, and how they are deserialized.

for example, ask them how many bytes and sizes their unsigned int and int are, and then write data in the corresponding way of buffer .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b375d8-2c07f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b375d8-2c07f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?