Appendix G. DDE Overview

DDE (Dynamic Data Exchange) is a well-established mechanism for exchanging data among processes in MS-Windows. The mechanism was intentionally designed to be easy to use and to represent data as simply as possible. DDE is implemented in many popular programs that run in Windows, such as Microsoft Excel and Microsoft Word. This widespread availability makes DDE a good choice for general data sharing.

The competition with DDE is COM, with its variants for OLE: OPC and ActiveX. By comparison, DDE is simpler, and therefore faster, than the equivalent COM interface if implemented as a separate process. DDE is much easier to implement in code, and offers a particular data model as (name, value) pairs. In the case of real-time data, this model is well suited, and therefore offers the best cost/benefit ratio when programming for real-time data.

However, DDE was not designed to be used over a network. The Cogent solution for this shortcoming is to tunnel two OPC DataHubs over a network or the Internet using TCP. Thus, two programs that use only DDE can exchange data across a robust, TCP-enabled link.

Data Definitions

DDE defines data in terms of (service, topic, item), explained as follows:

service

A name used by a DDE server to identify its service to DDE clients. The default DDE service name for the OPC DataHub is datahub. Unlike most Windows programs, the OPC DataHub lets you change this name, or add more names if you'd like.

topic

A way to categorize items. This corresponds to a OPC DataHub domain.

item

A variable that holds a value. This corresponds to a OPC DataHub point.

Here are some service and topic names for several Windows programs:

ApplicationDDE Service NameDDE Topic Name
OPC DataHubMultiple names can be assigned. The default name is datahub.Any OPC DataHub domain name, the default domain is default.
Microsoft ExcelEXCELThe name of the spreadsheet, chart, macro, etc. For example: mysheet.xls
Microsoft AccessMSACCESSThe name of the table, SQL query, or macro to run.
Microsoft WordWINWORDThe name of the document, including the .doc extension.
FoxProFOXPRO
InTouch ViewerVIEWTAGNAME
FIX DMACSDMDDEDATA
National Instruments' LookoutLOOKOUTThe name of the application, without the .lkp extension.
Asymetrix ToolbookTOOLBOOKThe name of the toolbook application, with the .tbk extension.

Here are a few service and topic names for financial data feeds:

Data FeedDDE Service NameDDE Topic NameSymbol Example
ADP SharkMLLP IBM.N.Q
BloombergBLPMIBM EQUITY,[LAST TRADE]
BridgeBDDETKR@USH8/LS
FXCMFXPSBIDEUR/USD
Future Source (CalcSource)CALCSRCPUSH8.LAST
Future Source (ProfNet)PROFDDELIVEAPIU02,LAST
Knight Rider Profit CenterQMASTERQUOTEUSH8.LAST
METATRADERMTBIDUSDCHF
METATRADER v. 4MT4BIDUSDCHF
MGFOREXMGFOREXRATESUSD
MoneycastWBSERVERSES19/L (19 is a stock code)
ReutersREUTERIDNUSH8 /IBM ,LAST
Telerate WorkStationTWINDDEQUOTES USH8.3 LAST
Universal Market Data ServerUSDDEQUOTEUS8H;LAST

Client and Server

In DDE, the role of client and server in data exchange is fairly clear. A client initiates the activity, and the server responds. To facilitate two-way data transfer, each OPC DataHub can each act as both client and server. This is what allows Excel spreadsheets to share data bidirectionally across a network.

Sending and Receiving Data

There are three ways to send and receive ordinary data over DDE. Here is a brief explanation, using the OPC DataHub and Microsoft Excel as examples:

Poke The client sends data for an item directly to the server. In Excel, this is done with a macro. The server does not necessarily reply. The actual data flow is from client to server—from Excel to DataHub.

Request The client asks the server to send an item's data. In Excel, this is done with a macro. The client receives either the requested value, or NULL if the server can't send the value. The actual data flow is from server to client—from DataHub to Excel.

Advise The client asks to be notified of any change in the data for an item. If the server agrees to the request, it sends the new value for the item each time its value changes. The OPC DataHub can conduct two-way communication with Excel using only this advise capability, as follows: