0

I have to use the two functions to convert the transmission data between client and server, the problem is that the data buffer must necessarily be uint8_t but ntohs and htons want uint16_t otherwise they don't work; so I have to bring the data into uint16_t and convert it back to uint8_t. but the data converted and brought to uint8_t are null, that is '0'. where am i wrong? the code:

the busybee
  • 10,755
  • 3
  • 13
  • 30
Bob02
  • 1

1 Answers1

0

You don't need to use the htons or ntohs functions for a uint8_t variable, since it is only one byte. You htons/ntohs for uint16_t variables and htonl/ntohl for uint32_t variables.

Check this link, this might help you.

Roshin Raphel
  • 2,612
  • 4
  • 22
  • 40