Sign in to follow this  
klajntib

Directplay client and server in same app

Recommended Posts

klajntib    122
[UPDATED with new discoveries] Hi everyone! :) I'm currently doing the multiplayer code in a game.. and I'm trying to initialize a DirectPlay8Server interface and then a DirectPlay8Client interface in the same application, but it isn't working. If I start only the server and start hosting and then shutdown everything works OK. If I start only the client I can also shut it create it and shut it down properly. Debug output from dplay doesn't give me any suspicious errors or anything. If I create an exe with only the server running and one with only the client running I can succesfully connect to the server and communicate with it. Everything works fine. But if I try to create the server and the client at the same time in the same exe, everything seems to work, but when I try to release the last interface everything crashes with a memory leak. If i release the client first, and the server later then it crashes in the server->release(). If i release the server first and the client later it crashes at client->release(). So the order in which I init and release the client and the server doesn't matter. Both interfaces are encapsulated inside two classes and cannot access each other and alter each other's data. And this happens when I create and destroy the interfaces without hosting and connecting... [update] Just found out that if I create the server and the client, start hosting on the server and then immediately stop hosting and release both interfaces it doesn't crash. It seems as though it crashes when I let the update run (which does nothing on my part) - just an empty event handler for DPlay and that's it. Anybody got any ideas? Are there any known conflicts when running both the client and the server from the same app? My delete procedure is as follows: - stop the server/disconnect client - cancelasyncoperation (all) - interface->release() PS: I've found no samples whatsoever doing a listen server with directplay. [Edited by - klajntib on August 4, 2004 3:20:19 PM]

Share this post


Link to post
Share on other sites
klajntib    122
Hmm, i'll check it, but all mi CoInitializeEx and CoUninitialize calls are done in constructors and destructors, so all inits should have their respective uninits. :) Hopefully :P

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
OMG!
EAX screwed my DirectPlay! Seriously!

I used CoInitializeEx( NULL , COINIT_MULTITHREADED ) to initialize COM since it says in the documentation that using the singlethreaded CoInitialize( NULL ) with DirectPlay could cause "serious race conditions". Can anyone translate this?

The unfortunate thing is that EAX screws up when using the multithreaded version so i'm now using the single threaded version and hope that DirectPlay won't have any problems.

Share this post


Link to post
Share on other sites
klajntib    122
Yeah.. EAX (Creative's Environmental Audio Extensions). We are using EAX through DirectSound. At first we were creating DirectSound with EAXDirectSound8Create instead of just using DirectSound8Create. This worked fine with the single threaded COM model. But DirectPlay prefered the multithreaded COM model and when I changed that it somehow screws up EAXDirectSound8Create and causes and access violation on shutdown. Createing EAX with CoCreateInstance fails when using multithreaded COM, but works when using singlethreaded COM.

So EAXDirectSound8Create somehow managed to screw things up. I'm using singlethreaded COM now and just hope that it doesn't fook up DirectPlay :)

Share this post


Link to post
Share on other sites
best of luck then, although i should note that DSound is really easy to use once you get past the initialization drama. the only real hassle is if you are doing a ton of effects or need to do alot of streaming.

3d sound is pretty easy once you get past the init issues as well.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this