]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/tcpconn.tex
Moved desktop margin options to a more sensible place
[wxWidgets.git] / docs / latex / wx / tcpconn.tex
CommitLineData
e2a6f233
JS
1\section{\class{wxTCPConnection}}\label{wxtcpconnection}
2
3A wxTCPClient object represents the connection between a client and a server.
4It emulates a DDE-style protocol, but uses TCP/IP which is available on most platforms.
5
6A DDE-based implementation for Windows is available using \helpref{wxDDEConnection}{wxddeconnection}.
7
8A wxTCPConnection object can be created by making a connection using a\rtfsp
9\helpref{wxTCPClient}{wxtcpclient} object, or by the acceptance of a connection by a\rtfsp
10\helpref{wxTCPServer}{wxtcpserver} object. The bulk of a conversation is controlled by
11calling members in a {\bf wxTCPConnection} object or by overriding its
12members.
13
14An application should normally derive a new connection class from
15wxTCPConnection, in order to override the communication event handlers
16to do something interesting.
17
18\wxheading{Derived from}
19
20wxConnectionBase\\
21\helpref{wxObject}{wxobject}
22
954b8ae6
JS
23\wxheading{Include files}
24
25<wx/sckipc.h>
26
a7af285d
VZ
27\wxheading{Library}
28
29\helpref{wxNet}{librarieslist}
30
e2a6f233
JS
31\wxheading{Types}
32
33\index{wxIPCFormat}wxIPCFormat is defined as follows:
34
35\begin{verbatim}
36enum wxIPCFormat
37{
38 wxIPC_INVALID = 0,
39 wxIPC_TEXT = 1, /* CF_TEXT */
40 wxIPC_BITMAP = 2, /* CF_BITMAP */
41 wxIPC_METAFILE = 3, /* CF_METAFILEPICT */
42 wxIPC_SYLK = 4,
43 wxIPC_DIF = 5,
44 wxIPC_TIFF = 6,
45 wxIPC_OEMTEXT = 7, /* CF_OEMTEXT */
46 wxIPC_DIB = 8, /* CF_DIB */
47 wxIPC_PALETTE = 9,
48 wxIPC_PENDATA = 10,
49 wxIPC_RIFF = 11,
50 wxIPC_WAVE = 12,
50c549b9 51 wxIPC_UTF16TEXT = 13, /* CF_UNICODE */
e2a6f233
JS
52 wxIPC_ENHMETAFILE = 14,
53 wxIPC_FILENAME = 15, /* CF_HDROP */
54 wxIPC_LOCALE = 16,
50c549b9
VZ
55 wxIPC_UTF8TEXT = 17,
56 wxIPC_UTF32TEXT = 18,
57#if SIZEOF_WCHAR_T == 2
58 wxIPC_UNICODETEXT = wxIPC_UTF16TEXT,
59#elif SIZEOF_WCHAR_T == 4
60 wxIPC_UNICODETEXT = wxIPC_UTF32TEXT,
61#endif
e2a6f233
JS
62 wxIPC_PRIVATE = 20
63};
64\end{verbatim}
65
66\wxheading{See also}
67
68\helpref{wxTCPClient}{wxtcpclient}, \helpref{wxTCPServer}{wxtcpserver}, \helpref{Interprocess communications overview}{ipcoverview}
69
70\latexignore{\rtfignore{\wxheading{Members}}}
71
f510b7b2 72\membersection{wxTCPConnection::wxTCPConnection}\label{wxtcpconnectionctor}
e2a6f233
JS
73
74\func{}{wxTCPConnection}{\void}
75
9bf6a1b8 76\func{}{wxTCPConnection}{\param{void* }{buffer}, \param{size\_t}{ size}}
e2a6f233
JS
77
78Constructs a connection object. If no user-defined connection object is
79to be derived from wxTCPConnection, then the constructor should not be
80called directly, since the default connection object will be provided on
81requesting (or accepting) a connection. However, if the user defines his
82or her own derived connection object, the \helpref{wxTCPServer::OnAcceptConnection}{wxtcpserveronacceptconnection}\rtfsp
83and/or \helpref{wxTCPClient::OnMakeConnection}{wxtcpclientonmakeconnection} members should be replaced by
84functions which construct the new connection object. If the arguments of
85the wxTCPConnection constructor are void, then a default buffer is
86associated with the connection. Otherwise, the programmer must provide a
87a buffer and size of the buffer for the connection object to use in
88transactions.
89
f510b7b2 90\membersection{wxTCPConnection::Advise}\label{wxtcpconnectionadvise}
e2a6f233 91
9bf6a1b8 92\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const void* }{data}, \param{size\_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
50c549b9 93
9bf6a1b8 94\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{size\_t }{size = (size\_t)-1}}
50c549b9 95
9bf6a1b8 96\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const wchar\_t* }{data}, \param{size\_t }{size = (size\_t)-1}}
50c549b9
VZ
97
98\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const wxString& }{data}}
e2a6f233
JS
99
100Called by the server application to advise the client of a change in
101the data associated with the given item. Causes the client
b2cf617c 102connection's \helpref{wxTCPConnection::OnAdvise}{wxtcpconnectiononadvise}
cc81d32f 103member to be called. Returns true if successful.
e2a6f233 104
f510b7b2 105\membersection{wxTCPConnection::Execute}\label{wxtcpconnectionexecute}
e2a6f233 106
9bf6a1b8 107\func{bool}{Execute}{\param{const void* }{data}, \param{size\_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
50c549b9 108
9bf6a1b8 109\func{bool}{Execute}{\param{const char* }{data}, \param{size\_t }{size = (size\_t)-1}}
50c549b9 110
9bf6a1b8 111\func{bool}{Execute}{\param{const wchar\_t* }{data}, \param{size\_t }{size = (size\_t)-1}}
50c549b9
VZ
112
113\func{bool}{Execute}{\param{const wxString& }{data}}
e2a6f233
JS
114
115Called by the client application to execute a command on the server. Can
116also be used to transfer arbitrary data to the server (similar
117to \helpref{wxTCPConnection::Poke}{wxtcpconnectionpoke} in that respect). Causes the
118server connection's \helpref{wxTCPConnection::OnExecute}{wxtcpconnectiononexecute} member to be
cc81d32f 119called. Returns true if successful.
e2a6f233 120
f510b7b2 121\membersection{wxTCPConnection::Disconnect}\label{wxtcpconnectiondisconnect}
e2a6f233
JS
122
123\func{bool}{Disconnect}{\void}
124
125Called by the client or server application to disconnect from the other
126program; it causes the \helpref{wxTCPConnection::OnDisconnect}{wxtcpconnectionondisconnect} message
127to be sent to the corresponding connection object in the other
128program. The default behaviour of {\bf OnDisconnect} is to delete the
129connection, but the calling application must explicitly delete its
cc81d32f 130side of the connection having called {\bf Disconnect}. Returns true if
e2a6f233
JS
131successful.
132
133\membersection{wxTCPConnection::OnAdvise}\label{wxtcpconnectiononadvise}
134
9bf6a1b8 135\func{virtual bool}{OnAdvise}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{const void* }{data}, \param{size\_t }{size}, \param{wxIPCFormat }{format}}
e2a6f233
JS
136
137Message sent to the client application when the server notifies it of a
138change in the data associated with the given item.
139
140\membersection{wxTCPConnection::OnDisconnect}\label{wxtcpconnectionondisconnect}
141
142\func{virtual bool}{OnDisconnect}{\void}
143
144Message sent to the client or server application when the other
145application notifies it to delete the connection. Default behaviour is
146to delete the connection object.
147
148\membersection{wxTCPConnection::OnExecute}\label{wxtcpconnectiononexecute}
149
9bf6a1b8 150\func{virtual bool}{OnExecute}{\param{const wxString\& }{topic}, \param{const void* }{data}, \param{size\_t }{size}, \param{wxIPCFormat}{ format}}
e2a6f233
JS
151
152Message sent to the server application when the client notifies it to
153execute the given data. Note that there is no item associated with
154this message.
155
156\membersection{wxTCPConnection::OnPoke}\label{wxtcpconnectiononpoke}
157
9bf6a1b8 158\func{virtual bool}{OnPoke}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{const void* }{data}, \param{size\_t }{size}, \param{wxIPCFormat }{format}}
e2a6f233
JS
159
160Message sent to the server application when the client notifies it to
161accept the given data.
162
163\membersection{wxTCPConnection::OnRequest}\label{wxtcpconnectiononrequest}
164
9bf6a1b8 165\func{virtual const void*}{OnRequest}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{size\_t *}{size}, \param{wxIPCFormat }{format}}
e2a6f233
JS
166
167Message sent to the server application when the client
168calls \helpref{wxTCPConnection::Request}{wxtcpconnectionrequest}. The server
169should respond by returning a character string from {\bf OnRequest},
170or NULL to indicate no data.
171
172\membersection{wxTCPConnection::OnStartAdvise}\label{wxtcpconnectiononstartadvise}
173
174\func{virtual bool}{OnStartAdvise}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}}
175
176Message sent to the server application by the client, when the client
177wishes to start an `advise loop' for the given topic and item. The
cc81d32f 178server can refuse to participate by returning false.
e2a6f233
JS
179
180\membersection{wxTCPConnection::OnStopAdvise}\label{wxtcpconnectiononstopadvise}
181
182\func{virtual bool}{OnStopAdvise}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}}
183
184Message sent to the server application by the client, when the client
185wishes to stop an `advise loop' for the given topic and item. The
cc81d32f 186server can refuse to stop the advise loop by returning false, although
e2a6f233
JS
187this doesn't have much meaning in practice.
188
189\membersection{wxTCPConnection::Poke}\label{wxtcpconnectionpoke}
190
9bf6a1b8 191\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const void* }{data}, \param{size\_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
50c549b9 192
9bf6a1b8 193\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{size\_t }{size = (size\_t)-1}}
50c549b9 194
9bf6a1b8 195\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const wchar\_t* }{data}, \param{size\_t }{size = (size\_t)-1}}
50c549b9
VZ
196
197\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const wxString& }{data}}
e2a6f233
JS
198
199Called by the client application to poke data into the server. Can be
200used to transfer arbitrary data to the server. Causes the server
201connection's \helpref{wxTCPConnection::OnPoke}{wxtcpconnectiononpoke} member
cc81d32f 202to be called. Returns true if successful.
e2a6f233
JS
203
204\membersection{wxTCPConnection::Request}\label{wxtcpconnectionrequest}
205
9bf6a1b8 206\func{const void*}{Request}{\param{const wxString\& }{item}, \param{size\_t *}{size}, \param{wxIPCFormat }{format = wxIPC\_TEXT}}
e2a6f233
JS
207
208Called by the client application to request data from the server. Causes
209the server connection's \helpref{wxTCPConnection::OnRequest}{wxtcpconnectiononrequest} member to be called. Returns a
210character string (actually a pointer to the connection's buffer) if
211successful, NULL otherwise.
212
213\membersection{wxTCPConnection::StartAdvise}\label{wxtcpconnectionstartadvise}
214
215\func{bool}{StartAdvise}{\param{const wxString\& }{item}}
216
217Called by the client application to ask if an advise loop can be started
218with the server. Causes the server connection's \helpref{wxTCPConnection::OnStartAdvise}{wxtcpconnectiononstartadvise}\rtfsp
cc81d32f 219member to be called. Returns true if the server okays it, false
e2a6f233
JS
220otherwise.
221
222\membersection{wxTCPConnection::StopAdvise}\label{wxtcpconnectionstopadvise}
223
224\func{bool}{StopAdvise}{\param{const wxString\& }{item}}
225
226Called by the client application to ask if an advise loop can be
227stopped. Causes the server connection's \helpref{wxTCPConnection::OnStopAdvise}{wxtcpconnectiononstopadvise} member
cc81d32f 228to be called. Returns true if the server okays it, false otherwise.
e2a6f233 229