I am working with a project which uses a custom TCP protocol. I have everything down the line, except for one thing: The protocol requires 4 bites before the message, that determine the length of the package. In NodeJS, this is done via:
var b = new Buffer(4);
b.writeUInt32BE(data.length, 0);
But is there such a way in PHP also? I was considering using pack()
- but I have no experience with this function. I also need to read a package of the same format, so I also need to be able to obtain the integer from the first 4 bites too.
Aucun commentaire:
Enregistrer un commentaire