Changing an IP address?


i have an issue that i just cant understand. im sure the solution is very simple and im just missing something.

So i have an Audio application that on launch runs the following function

void MainComponent::ConnectOSC()
static Identifier IpProperty(“IP”);
auto newTree(Tree);
TargetIP = newTree.getProperty(IpProperty);
if (OSCsend.connect (TargetIP, 53000));
std::cout << "\n OSC conect has been caled and has conected to: " << TargetIP;

this works fine and connects to the correct IP. but…

i want the user to be able to change the IP. I do this by changing the value tree and using a value tree listener I disconnect the OSC sender and then run ConnectOSC() again.

        if (OSCsend.disconnect())
            std::cout << " \n disconected from OSC \n ";

the result sends the correct IP address to the console but does not connect to that address. in fact it seems to stay disconnected.

any ideas?