/////////////////////////////////////////////////////////////////////////////
/*!
-
+
@page ipc_overview Interprocess communication overview
-
+
Classes: #wxServer,
#wxConnection,
#wxClient
interprocess communication and network programming. This section
only discusses one family of classes -- the DDE-like protocol --
but here's a list of other useful classes:
-
-
+
+
#wxSocketEvent,
#wxSocketBase,
#wxSocketClient,
#wxSocketServer: classes for the low-level TCP/IP API.
#wxProtocol, #wxURL, #wxFTP, #wxHTTP: classes
for programming popular Internet protocols.
-
-
+
+
wxWidgets' DDE-like protocol is a high-level protocol based on
Windows DDE. There are two implementations of this DDE-like
protocol: one using real DDE running on Windows only, and another
equivalent wxTCP... and wxDDE... classes can be used in much the
same way.
Three classes are central to the DDE-like API:
-
-
+
+
wxClient. This represents the client application, and is used
only within a client program.
wxServer. This represents the server application, and is used
client to the server - both the client and the server use an
instance of this class, one per connection. Most DDE transactions
operate on this object.
-
-
+
+
Messages between applications are usually identified by three
variables: connection object, topic name and item name. A data
string is a fourth element of some messages. To create a
overriding virtual functions in your class derived from
wxConnection allows you to handle the DDE messages.
To create a working server, the programmer must:
-
-
+
+
Derive a class from wxConnection, providing handlers for various messages sent to the server
side of a wxConnection (e.g. OnExecute, OnRequest, OnPoke). Only
the handlers actually required by the application need to be
derived connection class if the connection is accepted.
Create an instance of your server object and call Create to
activate it, giving it a service name.
-
-
+
+
To create a working client, the programmer must:
-
-
+
+
Derive a class from wxConnection, providing handlers for various
messages sent to the client side of a wxConnection (e.g.
OnAdvise). Only the handlers actually required by the application
a connection object of the derived class if the connection is
successful.
Use the wxConnection member functions to send messages to the server.
-
-
+
+
@ref datatransfer_overview
#Examples
@ref ddedetails_overview
-
-
+
+
@section datatransfer Data transfer
-
+
These are the ways that data can be transferred from one
application to another. These are methods of wxConnection.
-
-
+
+
@b Execute: the client calls the server with a data string representing
a command to be executed. This succeeds or fails, depending on the
server's willingness to answer. If the client wants to find the result
@b Advise: The client asks to be advised of any change in data
associated with a particular item. If the server agrees, the server will
send an OnAdvise message to the client along with the item and data.
-
-
+
+
The default data type is wxCF_TEXT (ASCII text), and the default data
size is the length of the null-terminated string. Windows-specific data
types could also be used on the PC.
-
+
@section ipcexamples Examples
-
+
See the sample programs @e server and @e client in the IPC
samples directory. Run the server, then the client. This demonstrates
using the Execute, Request, and Poke commands from the client, together
with an Advise loop: selecting an item in the server list box causes
that item to be highlighted in the client list box.
-
+
@section ddedetails More DDE details
-
+
A wxClient object initiates the client part of a client-server
DDE-like (Dynamic Data Exchange) conversation (available in both
Windows and Unix).
member can return a wxConnection of the required class, when a
connection is made.
For example:
-
+
@code
class MyConnection: public wxConnection {
public:
bool OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format)
{ wxMessageBox(topic, data); }
};
-
+
class MyClient: public wxClient {
public:
MyClient(void) {}
wxConnectionBase *OnMakeConnection(void) { return new MyConnection; }
};
@endcode
-
+
Here, @b MyConnection will respond to
#OnAdvise messages sent by the
server by displaying a message box.
request for a connection is accepted, and the client then
requests an @e Advise loop from the server (an Advise loop is
where the server calls the client when data has changed).
-
+
@code
wxString server = "4242";
wxString hostName;
wxGetHostName(hostName);
-
+
// Create a new client
MyClient *client = new MyClient;
connection = (MyConnection *)client-MakeConnection(hostName, server, "IPC TEST");
-
+
if (!connection)
{
wxMessageBox("Failed to make connection to server", "Client Demo Error");
}
connection-StartAdvise("Item");
@endcode
-
+
*/
-
-
+
+