Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DDE across a network

Posted on 1998-06-01
15
Medium Priority
?
769 Views
Last Modified: 2013-12-03
I'm trying to use DDE between two machines connected thru a network, where the DDE client resides on one machine, and the DDE server resides on another. When i make the call to DdeConnect (and later the call to DdeClientTransaction), no problems, if the DDE server on the other machine is up and running. Data values come in, all is bliss. If the DDE server goes down, i get the disconnection message, great.

However, if the DDE server on the other machine is NOT up when i call DdeConnect, the call to it and to DdeClientTransaction both return success - no error. I assume this is because they are actually done asynchronously, to stop holding the program up. However, because (I assume) there is NO DDE server on the other end, my client end never gets told that the connection couldn't really be set up. The upshot of all this is if the DDE server isn't up when the client end starts up, everything seems to work fine, but i can never find out that the DDE server isn't there - so i just get no values at all.

Any suggestions?
0
Comment
Question by:chris_cse
  • 5
  • 4
  • 2
  • +3
15 Comments
 
LVL 7

Expert Comment

by:BlackMan
ID: 1405957
According to MS documentation, if DdeConnect fails, it will return 0 and DdeGetLastError wil return something like DMLERR_NO_CONV_ESTABLISHED.
Are you getting a handle back from DdeConnect ?
0
 

Author Comment

by:chris_cse
ID: 1405958
DdeConnect is returning what appears to be a valid conversation handle - certainly non-zero.
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1405959
Have you checked DdeGetLastError ?
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:chris_cse
ID: 1405960
No, i didn't see much point...DdeGetLastError returns gods-alone-know-what if there wasn't an error...certainly you can't rely on DdeGetLastError returning 0 if there WAS no last error
0
 
LVL 6

Expert Comment

by:alamo
ID: 1405961
In my experience, "gods-alone-know-what" is often "16390 A parameter failed to be validated by the DDEML." :-) On NT, at least.

I have been working on a project involving DDE where NetDDE isn't critical at this stage, so I haven't looked closely at it when it fails. My impression was it does block on a remote connect, waiting to find the result, but I wasn't paying close attention so can't say for sure.  (I was just thrilled to get it working at all, at the time). If noone has an answer for you in a couple of days I'll look at it and see if I see the same things.

By the way, have you considered setting up the server so it starts automatically when someone tries to connect?  That might lessen the problem.
0
 

Author Comment

by:chris_cse
ID: 1405962
Point taken, but it's documented that you should NOT refer to DdeGetLastError (or GetLastError, for that matter) if a call succeeds.

With the remote connect - the app. i'm writing has 5 values it needs to query, and for each value there are 5 categories. For each of THOSE, there is a current value, and a previous value. So a quick calculation reveals 50 DDE transactions...50 connects would grind the app to a stunning halt, if it waited for each to connect across a network, so i hope it doesn't wait...and it doesn't, or we'd be seeing response times in the toilet, and we're not.

And setting up the server automatically when someone starts to connect - a couple of problems there:
- it would mean a new process running on the other machine, to detect the attempt to connect to the DDE server, and the ONLY app that could detect that is one that is, itself, running the DDE server to which i'm trying to connect...full circle
- part of the problem with the server not being up is that the machine itself mightn't even be on!
0
 
LVL 6

Expert Comment

by:alamo
ID: 1405963
You should be able to connect once and then do all 50 requests using the same conversation. So it's Ok for the connect stage to take a while to set up, after which each transaction (request or execute) is quick. My impression that the connect step blocked was due to the fact it would sometimes have to present a login dialog in order to satisfy the dde share security. (But that could be an NT-only thing, I don't know).

One of the netdde options (set via ddeshare.exe) is to automatically start the server when a netdde request is made, that's what I meant about setting it up to start automatically. That still doesn't deal with the case where the machine is off- you could probably check for that from your program. It's not an ideal solution, I agree.

0
 

Author Comment

by:chris_cse
ID: 1405964
The problem is that i never know until run-time where each of the 50 items are - any or all of them could be on different machines (ie., possible 50 different DDE servers), so i connect to each separately. I COULD do a run-time comparison and only connect to the minimum necessary, but it would be a huge pain.

And none of this gets over the fact that the call to DdeConnect DOES return immediately, certainly long before the connect could have actually happened, and it DOES return success, when the server is not there??????????????????//
0
 
LVL 2

Expert Comment

by:abesoft
ID: 1405965
It looks like you have exhausted the "detect the error and report a problem at connect time" approach.  (Although it sounds like there might be other approaches that could work in that arena: detecting if the machine is on via MS-Networking, and then communicating with an auto-start server sounds likely, but you might not want to make the server auto-start...)

Perhaps you might want to solve the problem a different way.  If you can send an initial handshake transaction to the server, you could determine that the server isn't there by using a time-out on the transaction.  

You can also use this handshake to verify that the server and client can agree on their versions, etc.  I think it is always a good idea in a C/S environment to verify the server version....

Hope this helps!
0
 

Author Comment

by:chris_cse
ID: 1405966
For possibly 50 different servers? It would take too long!
0
 
LVL 2

Expert Comment

by:abesoft
ID: 1405967
Then why not spin up 50 threads, and then let them all attempt the connect simultaneously.  Yes, there will be overhead (in time and memory) but sometimes that's the way life is.
0
 

Expert Comment

by:MarcoC
ID: 1405968
DDE does not work reliably when used in different threads. All the DDE handling code must be in the same thread.
0
 
LVL 6

Expert Comment

by:alamo
ID: 1405969
Inter-thread DDE does not work, as MarcoC notes - but that doesn't mean you couldn't call DdeInitialize (with a separate callback function) for each of 50 threads.

But I don't think that is either necessary or a good idea. Let's get back to the original question - how do you know when a NDDE connection has failed? I just did some checking and found that I do indeed get a return code indicating success on the initial NDDE connection to a nonexistent machine. However, I can tell it had really failed by the fact that immediately thereafter I get a disconnect callback on that conversation.

So the question becomes,  chris_cse - could you double check that you are in fact not getting the disconnect in this situation? Perhaps you are but are not processing them because they are happening so quickly.

In my test program I am not doing an immediate transaction, so it's also conceivable that an immediate transaction somehow confuses NDDE (or causes it to swallow the  disconnect). Which transaction are you doing? I could try it here.

0
 
LVL 6

Accepted Solution

by:
alamo earned 400 total points
ID: 1405970
Since nothing for a few days, I'll repost as an answer what I found.

You do indeed get a return code indicating success on the initial NDDE connection to a nonexistent machine. However, you can tell it had really failed by the fact that soon (almost immediately) thereafter you get a disconnect.

Hope it's working for you, good luck!
0
 
LVL 2

Expert Comment

by:lortega
ID: 1405971
chris_cse you are using DDE over the net or NetDDE?


0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question