Possible to send a message to client without previous request from client?

Nov 21, 2012 at 8:00 PM

Hi,

I have the task to code a project which includes DDE. Found Ndde and it's really a great help for me, was able to integrate a DDE-Server into my application and made a small client for testing, thx a lot.

Here is my problem: I have to use a special format in which the first char in an item defines if the DDE message is a command or a request. That means I'm using POKE for sending commands and requests from the client to the server.

If I want to answer a request I would need a kind of POKE from the server to the client, but as far as I can see that's not possible. Or I'm wrong? How can I send an item from the server to the client without a previous request from the client?

thx for help

Nov 22, 2012 at 5:19 AM

what about advise (every change for the field can be published \ communicated to the client if the client subscribed to it by 'StartAdvise'  method )

Nov 22, 2012 at 8:05 AM

 

OK, but I have the problem that I have to transfer answers > 255 chars to the client.

With POKE no problem to transfer messages > 255 chars to the server, but how do I this from server to client?

Nov 24, 2012 at 5:10 AM

Have you checked the samples ? 

There is a very nice server\client sample which covers every scenario .

String in .net can be any length and I'm sure the NDDE lib will allow you to deliver a string (e.Text from DdeAdviseEventArgs)

Anyway here is a small sample from the server code

 protected override byte[] OnAdvise(string topic, string item, int format)
            {
                Console.WriteLine("OnAdvise:".PadRight(16)
                    + " Service='" + this.Service + "'"
                    + " Topic='" + topic + "'"
                    + " Item='" + item + "'"
                    + " Format=" + format.ToString());

                // Send data to the client only if the format is CF_TEXT.
                if (format == 1)
                {
                    return System.Text.Encoding.ASCII.GetBytes("Time=" + DateTime.Now.ToString() + "\0" );
                }
                return null;
            }