Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Directplay SendTo quest

This topic is 5326 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

Hi. i have some questions about the function SendTo in Directplay. 1) if im using assyncronous sendTo, does i need to use SEND_GARANTEED to make sure that the msg will arrive? if the SendTo fails, how can i know that? where can a deal with the error? (callback function??). if i use the following simplified piece of code: XXX *data = new XXX; ... directplay->SendTo(....,....,...,..,...). delete data; im sending the data trought the network but asyncronous. if i delete the data after the SendTo function, will directplay send the correct data??? (because it was already deleted). In Syncronous SendTo there is no need to worry..but in Assync i really dont know. Thats all...Thanks....

Share this post

Link to post
Share on other sites
You need to pass DPNSEND_GUARANTEED if you want to use a guaranteed delivery mechanism. The send can still fail if the remote computer is disconnected from the session before the message is sent though.

Deleting the buffer right after the SendTo() call is fine, as long as you didn''t pass DPNSEND_NOCOPY. The normal operation of a Send/SendTo call is for DirectX to allocate an internal buffer, copy your buffer there, then send it''s internal buffer. DPNSEND_NOCOPY is a flag that prevents this copy, instead letting DirectPlay send your buffer directly. The benefit of using the flag is that you save yourself a memcopy, the drawback is that you have to make sure your buffer remains valid until the data has been successfully sent.

From the docs:


When the SendTo request is completed, a DPN_MSGID_SEND_COMPLETE system message is posted to the sender''s message handler. The success or failure of the request is contained in the hResultCode member of the associated structure. You can suppress the send completion by setting the DPNSEND_NOCOMPLETE flag in dwflags.

Send completions are typically posted on the source computer as soon as the message is sent. In other words, a send completion does not necessarily mean that the message has been processed on the target. It may still be in a queue. If you want to be certain that the message has been processed by the target, set the DPNSEND_COMPLETEONPROCESS flag in dwFlags. This flag ensures that the send completion will not be sent until the target''s message handler has processed the message, and returned.

Note Do not assume that resources such as the data buffer will remain valid until the method has returned. If you call this method asynchronously, the DPN_MSGID_SEND_COMPLETE message may be received and processed by your message handler before the call has returned. If your message handler deallocates or otherwise invalidates a resource such as the data buffer, that resource may become invalid at any time after the method has been called.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!