Howdy Wamor,
A socket number of 0 is fine ... it is merely an integer handle that represents a channel for communication and the first one you create can be 0. If socket() returned -1 then there would have been an issue. Based on the information you presented, my first guess is that you might have a mis-understanding on datagrams and sockets(). The ESP32 implements a pretty clean distribution of the sockets() API and a solid study of sockets programming outside the scope of the ESP32 would do no harm. In fact, for many tasks, actually developing your sockets logic on a PC (eg. Linux) would do no harm and the port to ESP32 should be trivial.
What I think I am seeing is that sockets() is an API on TCP/IP and TCP/IP has two distinct higher level protocols. These are TCP for connection oriented data transmission and UDP for data grams (fire and forget). The socket you created is a datagram socket. What that means is that it isn't "connected" to a partner. As such, when you wish to send a datagram, you need to instruct the environment where you wish to send it. This can be accomplished by using the sockets API called "sendto()" ... see:
https://linux.die.net/man/2/sendto
which takes a destination address (IP and port) as additional parameters as compared to send().
Now this isn't the only way to send data grams, I believe one can bind an address to a data gram socket ... but without seeing more of the logic/design, I can't say for sure what the issue may be ... but the above might be a sensible guess.