So I have this really weird bug with I have been trying to fix for the past 3 days.
I basically have 2 applications, one is the game, the other one is an editor.
I connect them together so I can send data around.
The game has a listening socket and the editors just try to connect to it every once in a few seconds.
This works fine, but there is this really weird and specific bug.
I have the option to launch an instance of the editor from the game.
When I do this (using anything from sytem to CreateProcess, I tried them all), the editor launches and connects as expected.
When I then shut down the game the editor loses connection.
But here is where it gets weird.
For some reason the next time it tries to connect, it succeeds.
Even though the game is not running.
Then it disconnects because it doesn't receive any ping message (because there is no game to send them) and thinks that it has timed out.
After that, it reconnects again.
And it just keeps doing this over and over.
And this just happens when I start the process from the game.
When I launch the editor seperately, this does not happen, and everything works perfectly.
So I hope that any of you have any idea what is going on here, because I really don't know anymore.
After some more debugging I think I have found at least where it goes wrong (but still no idea why).
For some reason the sockets keeps hanging around when a process is launched from the game.
I tried starting notepad from the game, and then shutting the game down, and everything will think that the socket still exists.
The moment I shut down notepad however everything goes back to normal.
Now I played around a LOT with shutting down the socket.
I tried pretty much every way and step in between to shut it down, but none of them seem to fix the problem.
Even resetting everything everywhere, including calling WSAStartup and WSAShutdown does not seem to help.