- // Create the main frame window
- frame = new MyFrame(NULL, "Client", wxPoint(400, 0), wxSize(400, 300));
+ // service name (DDE classes) or port number (TCP/IP based classes)
+ wxString service = IPC_SERVICE;
+
+ // ignored under DDE, host name in TCP/IP based classes
+ wxString hostName = "localhost";
+
+ if (argc > 1)
+ service = argv[1];
+ if (argc > 2)
+ hostName = argv[2];
+
+ // Create a new client
+ my_client = new MyClient;
+
+ // suppress the log messages from MakeConnection()
+ {
+ wxLogNull nolog;
+ the_connection = (MyConnection *)
+ my_client->MakeConnection(hostName, service, IPC_TOPIC);
+
+ while ( !the_connection )
+ {
+ if ( wxMessageBox("Failed to make connection to server.\nRetry?",
+ "Client Demo Error",
+ wxICON_ERROR | wxYES_NO | wxCANCEL ) != wxYES )
+ {
+ // no server
+ return FALSE;
+ }
+
+ the_connection = (MyConnection *)my_client->MakeConnection(hostName, service, "IPC TEST");
+ }
+ }
+
+ if (!the_connection->StartAdvise(IPC_ADVISE_NAME))
+ wxMessageBox("StartAdvise failed", "Client Demo Error");
+
+ // Create the main frame window
+ (new MyFrame(NULL, "Client"))->Show(TRUE);