Solved

DDE across a network

Posted on 1998-06-01
15
755 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
Comment Utility
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
Comment Utility
DdeConnect is returning what appears to be a valid conversation handle - certainly non-zero.
0
 
LVL 7

Expert Comment

by:BlackMan
Comment Utility
Have you checked DdeGetLastError ?
0
 

Author Comment

by:chris_cse
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:chris_cse
Comment Utility
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
Comment Utility
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
Comment Utility
For possibly 50 different servers? It would take too long!
0
 
LVL 2

Expert Comment

by:abesoft
Comment Utility
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
Comment Utility
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
Comment Utility
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 200 total points
Comment Utility
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
Comment Utility
chris_cse you are using DDE over the net or NetDDE?


0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now