Jump to content
  • Advertisement
Sign in to follow this  

Winsock Multiprocess Issues

This topic is 2748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
The open socket handle is probably being inherited by the child process. You should look up on MSDN how to mark the handle as no-inherit before calling CreateProcess().

Share this post

Link to post
Share on other sites
Yes that seemed to be the problem.
Changing some settings in CreateProcess fixed the problem.
Thank you for your help.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!