Y
Y
Yaroslav Ivanov2019-08-02 00:33:04
Node.js
Yaroslav Ivanov, 2019-08-02 00:33:04

How to properly receive packets through node.js tcp server?

There is a tcp server on node.js through the standard net module.
There is a client that sends packets in ascii encoding.
The encoding on the server is as follows: socket.setEncoding("ascii");
The problem is that the packets are "broken".
If you listen through wireshark, then everything is ok.
wireshark package (Highlighted some different bytes):

32 00 3c 07 53 ab 4f 6f c5 3c f4 22 45 c2 41 0e 38 8c ce

Package via node.js tcp:
32 00 3c 07 53 2b 4f 6f 45 3c 74 22 45 42 41 0E 38 0c 4e 39 53 23 2c 61
27 1a 0d 2d 41 44 78 22 29 36 76 62 4a 79 7e 01 6d 06 41 7c 6b March 14 1b 06 4d

How can this be influenced? Can some other module be used for tcp server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2019-08-02
@space2pacman

Maybe you should read the doc carefully?
https://nodejs.org/api/buffer.html#buffer_buffers_...
it is clearly written, 7-bit encoding, the high bit is cut off, which is what happens in your case

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question