Initialisation of GUI app

This is on Windows 10. I have a number of ‘C’ libs built into my application. I need to initialise these before I start the GUI. My ‘C’ initialise does nothing special but it does create a broadcast UDP socket. If I do this before:
mainWindow.reset (new MainWindow (getApplicationName()));
I get a strange error:
Failed to create broadcast socket! [-1475348720]
If I do it after creating the main window its fine. I don’t understand what the main window has to do with creating a socket.

I’ve worked round it but still interested to know why.