The way I solved a similar situation is using a MYSQL database in a webserver. Then the smartphone checks its own IP periodicly and updates it in the SQL database, together with its device ID.
When the desktop aplication needs to comunicate with a particular device, user selects the device from the list of devices available, the desktop then fetches the IP address of that particular mobile device.
After that it connects to it. If an error ocurs that means that the device is no longer online, otherwise they start to comunicate and you can do whatever you want to do.
Its been working for a few days, without any problem so far.