]>
git.saurik.com Git - wxWidgets.git/blob - interface/sckipc.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxTCPServer class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A wxTCPServer object represents the server part of a client-server conversation.
14 It emulates a DDE-style protocol, but uses TCP/IP which is available on most
17 A DDE-based implementation for Windows is available using wxDDEServer.
23 wxTCPClient, wxTCPConnection, @ref overview_ipcoverview "IPC overview"
25 class wxTCPServer
: public wxObject
29 Constructs a server object.
34 Registers the server using the given service name. Under Unix, the
35 string must contain an integer id which is used as an Internet port
36 number. @false is returned if the call failed (for example, the port
37 number is already in use).
39 bool Create(const wxString
& service
);
42 When a client calls @b MakeConnection, the server receives the
43 message and this member is called. The application should derive a
44 member to intercept this message and return a connection object of
45 either the standard wxTCPConnection type, or of a user-derived type. If the
46 topic is "STDIO'', the application may wish to refuse the connection.
47 Under Unix, when a server is created the OnAcceptConnection message is
48 always sent for standard input and output.
50 virtual wxConnectionBase
* OnAcceptConnection(const wxString
& topic
);
58 A wxTCPClient object represents the client part of a client-server conversation.
59 It emulates a DDE-style protocol, but uses TCP/IP which is available on most
62 A DDE-based implementation for Windows is available using wxDDEClient.
64 To create a client which can communicate with a suitable server,
65 you need to derive a class from wxTCPConnection and another from wxTCPClient.
66 The custom wxTCPConnection class will intercept communications in
67 a 'conversation' with a server, and the custom wxTCPServer is required
68 so that a user-overridden wxTCPClient::OnMakeConnection member can return
69 a wxTCPConnection of the required class, when a connection is made.
75 wxTCPServer, wxTCPConnection, @ref overview_ipcoverview "Interprocess
76 communications overview"
78 class wxTCPClient
: public wxObject
82 Constructs a client object.
87 Tries to make a connection with a server specified by the host
88 (a machine name under Unix), service name (must
89 contain an integer port number under Unix), and a topic string. If the
90 server allows a connection, a wxTCPConnection object will be returned.
91 The type of wxTCPConnection returned can be altered by overriding
92 the OnMakeConnection() member to return your own
93 derived connection object.
95 wxConnectionBase
* MakeConnection(const wxString
& host
,
96 const wxString
& service
,
97 const wxString
& topic
);
100 The type of wxTCPConnection returned from a MakeConnection() call can
101 be altered by deriving the @b OnMakeConnection member to return your
102 own derived connection object. By default, a wxTCPConnection
105 The advantage of deriving your own connection class is that it will
106 enable you to intercept messages initiated by the server, such
107 as wxTCPConnection::OnAdvise. You may also want to
108 store application-specific data in instances of the new class.
110 wxConnectionBase
* OnMakeConnection();
113 Returns @true if this is a valid host name, @false otherwise.
115 bool ValidHost(const wxString
& host
);
120 @class wxTCPConnection
123 A wxTCPClient object represents the connection between a client and a server.
124 It emulates a DDE-style protocol, but uses TCP/IP which is available on most
127 A DDE-based implementation for Windows is available using wxDDEConnection.
129 A wxTCPConnection object can be created by making a connection using a
130 wxTCPClient object, or by the acceptance of a connection by a
131 wxTCPServer object. The bulk of a conversation is controlled by
132 calling members in a @b wxTCPConnection object or by overriding its
135 An application should normally derive a new connection class from
136 wxTCPConnection, in order to override the communication event handlers
137 to do something interesting.
143 wxTCPClient, wxTCPServer, @ref overview_ipcoverview "Interprocess
144 communications overview"
146 class wxTCPConnection
: public wxObject
151 Constructs a connection object. If no user-defined connection object is
152 to be derived from wxTCPConnection, then the constructor should not be
153 called directly, since the default connection object will be provided on
154 requesting (or accepting) a connection. However, if the user defines his
155 or her own derived connection object, the wxTCPServer::OnAcceptConnection
156 and/or wxTCPClient::OnMakeConnection members should be replaced by
157 functions which construct the new connection object. If the arguments of
158 the wxTCPConnection constructor are void, then a default buffer is
159 associated with the connection. Otherwise, the programmer must provide a
160 a buffer and size of the buffer for the connection object to use in
164 wxTCPConnection(void* buffer
, size_t size
);
169 Called by the server application to advise the client of a change in
170 the data associated with the given item. Causes the client
171 connection's OnAdvise()
172 member to be called. Returns @true if successful.
174 bool Advise(const wxString
& item
, const void* data
, size_t size
,
175 wxIPCFormat format
= wxIPC_PRIVATE
);
176 bool Advise(const wxString
& item
, const char* data
);
177 bool Advise(const wxString
& item
, const wchar_t* data
);
178 bool Advise(const wxString
& item
, const wxString data
);
182 Called by the client or server application to disconnect from the other
183 program; it causes the OnDisconnect() message
184 to be sent to the corresponding connection object in the other
185 program. The default behaviour of @b OnDisconnect is to delete the
186 connection, but the calling application must explicitly delete its
187 side of the connection having called @b Disconnect. Returns @true if
194 Called by the client application to execute a command on the server. Can
195 also be used to transfer arbitrary data to the server (similar
196 to Poke() in that respect). Causes the
197 server connection's OnExecute() member to be
198 called. Returns @true if successful.
200 bool Execute(const void* data
, size_t size
,
201 wxIPCFormat format
= wxIPC_PRIVATE
);
202 bool Execute(const char* data
);
203 bool Execute(const wchar_t* data
);
204 bool Execute(const wxString data
);
208 Message sent to the client application when the server notifies it of a
209 change in the data associated with the given item.
211 virtual bool OnAdvise(const wxString
& topic
,
212 const wxString
& item
,
218 Message sent to the client or server application when the other
219 application notifies it to delete the connection. Default behaviour is
220 to delete the connection object.
222 virtual bool OnDisconnect();
225 Message sent to the server application when the client notifies it to
226 execute the given data. Note that there is no item associated with
229 virtual bool OnExecute(const wxString
& topic
, const void* data
,
234 Message sent to the server application when the client notifies it to
235 accept the given data.
237 virtual bool OnPoke(const wxString
& topic
, const wxString
& item
,
243 Message sent to the server application when the client
244 calls Request(). The server
245 should respond by returning a character string from @b OnRequest,
246 or @NULL to indicate no data.
248 virtual const void* OnRequest(const wxString
& topic
,
249 const wxString
& item
,
254 Message sent to the server application by the client, when the client
255 wishes to start an 'advise loop' for the given topic and item. The
256 server can refuse to participate by returning @false.
258 virtual bool OnStartAdvise(const wxString
& topic
,
259 const wxString
& item
);
262 Message sent to the server application by the client, when the client
263 wishes to stop an 'advise loop' for the given topic and item. The
264 server can refuse to stop the advise loop by returning @false, although
265 this doesn't have much meaning in practice.
267 virtual bool OnStopAdvise(const wxString
& topic
,
268 const wxString
& item
);
272 Called by the client application to poke data into the server. Can be
273 used to transfer arbitrary data to the server. Causes the server
274 connection's OnPoke() member
275 to be called. Returns @true if successful.
277 bool Poke(const wxString
& item
, const void* data
, size_t size
,
278 wxIPCFormat format
= wxIPC_PRIVATE
);
279 bool Poke(const wxString
& item
, const char* data
);
280 bool Poke(const wxString
& item
, const wchar_t* data
);
281 bool Poke(const wxString
& item
, const wxString data
);
285 Called by the client application to request data from the server. Causes
286 the server connection's OnRequest() member to be called. Returns a
287 character string (actually a pointer to the connection's buffer) if
288 successful, @NULL otherwise.
290 const void* Request(const wxString
& item
, size_t * size
,
291 wxIPCFormat format
= wxIPC_TEXT
);
294 Called by the client application to ask if an advise loop can be started
295 with the server. Causes the server connection's OnStartAdvise()
296 member to be called. Returns @true if the server okays it, @false
299 bool StartAdvise(const wxString
& item
);
302 Called by the client application to ask if an advise loop can be
303 stopped. Causes the server connection's OnStopAdvise() member
304 to be called. Returns @true if the server okays it, @false otherwise.
306 bool StopAdvise(const wxString
& item
);