Search code examples
node.jstcpcharacter-encodingchar

Forbidden characters in a TCP packet


I'm trying to send data from my ESP8266 to a NodeJS TCP server, the connection and basic charakters (48-90) are working fine, but if I use others like ASCII-Code (0,1,2,3...) I don't get any usefull data out of it. So what I was thinking about that there are some character which aren't allowed to send over TCP/IP.

By the way, I'm using this to write to the server, and I work with the standard WiFi Client library

char arr[255]
for(int i = 0; i < 255; i++){
   arr[i] = (char)i;
}
client.print(arr);

Solution

  • On the TCP/IP level, any characters values can be sent. The protocol is often used to transfer binary data (e.g. SSH, FTP etc. do this).

    The problem is likely to be in your code adding the characters to the sent data or printing the received string.

    One thing you can do to determine if the problem is on the sending or receiving side is to use Wireshark on your server machine to capture the transmitted data and check if the bytes are actually sent or not.