OK, so... Let's imagine I have an esp board connected to my home network... And that I also have a laptop and a smartphone also connected to the same network... How can I establish a communication with the esp without previously knowing it's ip in the network?
The best solution is to run a MQTT broker (or a B4J server) and let all devices including the ESP module connect to the broker.
You need to know the ip address in order to connect to the ESP directly. You can configure your router to assign a fixed ip address. Another option is to use UDP to broadcast the ip address.