Duplicate thread, avoid this, please. You show int h = unhex(receivedFromUDP); and the message indicates a line string h = unhex(receivedFromUDP); You should try and be consistent in your error reporting... Beside, string's class is String, with a capital S. And as I wrote in the other thread, I don't think you receive hex data, but binary data. So unhex isn't useful.
"binary data is just 0 and 1" Technically, it is right, but technically, all data in a computer is just made of 0 and 1... By binary, we generally mean data that is not Ascii, not textual. Hexa data is actually just an Ascii representation of such binary data. If you transmit the "01F2" string, it is actually 48, 49, 70, 50 in decimal representation, or 0x30 0x31 0x46 0x32 in hexa representation, and I save you the binary representation... Ie. that's Ascii characters representing an hexa value. What you shown in the other thread was "binary" data, including 0x00 and similar, ie. non-Ascii bytes.