sending serial.read() via UDP

6v6gt:
You have now mentioned a phone, an ESP8266 and an ESP32.
Have I got this correct: You can successfully send UDP packets from an ESP8266 to your phone. You cannot, however, send UDP packets from an ESP32 to your phone ?
It is not really clear from your various code snippets where they are running and what their target is.

Going back to the problem you mentioned at the beginning:

This line of code has a good chance of working : Udp.write("tosend");
a) because it is a well formed cstring literal which will automatically have a null terminating character to mark its end.
b) because its value does not have to be fetched from somewhere like your Udp.write(tosend) which attempts to get a value indirectly from Serial.readString();

Incidentally, Serial.readString() times out after 1 second (by default) so there may be a good chance that at the time it executed, no data was available. The first thing to check with debug statements is if this actually worked.

Further, the Udp.write(tosend) statement requires a length in bytes e.g. Udp.write(tosend, 20) otherwise it assumes the argument is one byte long.

Thanks a lot for the help. Yes you got it write!
Here is the deal: the Udp.write("tosend") works with both receivers (phone and ESP32) however the Udp.write(tosend) works with only my phone.
Now, why would the Serial.readString() be the problem since it has worked with my phone in the first place? just asking to understand.
Another things, I am very new to this, what do you mean by debug statement?
Regards,