]>
Commit | Line | Data |
---|---|---|
e79848ac GL |
1 | \section{\class{wxSocketBase}}\label{wxsocketbase} |
2 | ||
3 | \wxheading{Derived from} | |
4 | ||
5 | \helpref{wxEvtHandler}{wxevthandler} | |
6 | ||
954b8ae6 JS |
7 | \wxheading{Include files} |
8 | ||
9 | <wx/socket.h> | |
10 | ||
407f3681 | 11 | \wxheading{wxSocket errors} |
aa6d9706 GL |
12 | |
13 | \twocolwidtha{7cm} | |
14 | \begin{twocollist}\itemsep=0pt | |
15 | \twocolitem{{\bf wxSOCKET\_NOERROR}}{No error happened.} | |
16 | \twocolitem{{\bf wxSOCKET\_INVOP}}{Invalid operation.} | |
17 | \twocolitem{{\bf wxSOCKET\_IOERR}}{Input/Output error.} | |
18 | \twocolitem{{\bf wxSOCKET\_INVADDR}}{Invalid address passed to wxSocket.} | |
19 | \twocolitem{{\bf wxSOCKET\_INVSOCK}}{Invalid socket (uninitialized).} | |
20 | \twocolitem{{\bf wxSOCKET\_NOHOST}}{No corresponding host.} | |
21 | \twocolitem{{\bf wxSOCKET\_INVPORT}}{Invalid port.} | |
cf85cb95 GRG |
22 | \twocolitem{{\bf wxSOCKET\_WOULDBLOCK}}{The socket is non-blocking and the operation would block.} |
23 | \twocolitem{{\bf wxSOCKET\_TIMEDOUT}}{The timeout for this operation expired.} | |
aa6d9706 GL |
24 | \twocolitem{{\bf wxSOCKET\_MEMERR}}{Memory exhausted.} |
25 | \end{twocollist}% | |
26 | ||
7e9a386e | 27 | \wxheading{wxSocket events} |
5a96d2f4 | 28 | |
aa6d9706 GL |
29 | \twocolwidtha{7cm} |
30 | \begin{twocollist}\itemsep=0pt | |
cf85cb95 | 31 | \twocolitem{{\bf wxSOCKET\_INPUT}}{Some data has arrived to the socket.} |
aa6d9706 | 32 | \twocolitem{{\bf wxSOCKET\_OUTPUT}}{The socket is ready to be written to.} |
cf85cb95 GRG |
33 | \twocolitem{{\bf wxSOCKET\_CONNECTION}}{Incoming connection arrival (server), or connection establishment (client).} |
34 | \twocolitem{{\bf wxSOCKET\_LOST}}{The connection has been closed.} | |
aa6d9706 GL |
35 | \twocolitem{{\bf wxSOCKET\_MAX\_EVENT}}{This should never happen but the compiler may complain about it.} |
36 | \end{twocollist}% | |
5a96d2f4 | 37 | |
cf85cb95 GRG |
38 | A brief note on how to use these events: |
39 | ||
40 | The {\bf wxSOCKET\_INPUT} event will be issued when the incoming queue | |
41 | was empty and new data arrives, but NOT if new data arrives when there | |
42 | was data waiting in the incoming queue. | |
43 | ||
44 | The {\bf wxSOCKET\_OUTPUT} event is issued when a socket is first connected | |
45 | with Connect or accepted with Accept, and then, only after an output operation | |
46 | fails because the output buffer was full, and buffer space becomes available | |
47 | again. | |
48 | ||
49 | The {\bf wxSOCKET\_CONNECTION} event is issued when a connection request | |
50 | completes (client) or when a new connection arrives at the pending | |
51 | connections queue (server). | |
52 | ||
53 | The {\bf wxSOCKET\_LOST} event is issued when a close indication is | |
54 | received for the socket. This means that the connection broke down or | |
55 | that it was closed by the peer. | |
56 | ||
e79848ac GL |
57 | % --------------------------------------------------------------------------- |
58 | % Event handling | |
59 | % --------------------------------------------------------------------------- | |
60 | \wxheading{Event handling} | |
61 | ||
62 | To process events from a socket, use the following event handler macro to direct | |
cf85cb95 | 63 | input to member functions that take a \helpref{wxSocketEvent}{wxsocketevent} argument. |
e79848ac | 64 | |
42ff6409 | 65 | \twocolwidtha{7cm}% |
e79848ac GL |
66 | \begin{twocollist}\itemsep=0pt |
67 | \twocolitem{{\bf EVT\_SOCKET(id, func)}}{A socket event occured.} | |
68 | \end{twocollist}% | |
69 | ||
70 | % --------------------------------------------------------------------------- | |
71 | % See also ... | |
72 | % --------------------------------------------------------------------------- | |
e79848ac GL |
73 | \wxheading{See also} |
74 | ||
407f3681 JS |
75 | \helpref{wxSocketEvent}{wxsocketevent}, |
76 | \helpref{wxSocketClient}{wxsocketclient}, | |
9f3430a6 | 77 | \helpref{wxSocketServer}{wxsocketserver} |
e79848ac GL |
78 | |
79 | % --------------------------------------------------------------------------- | |
80 | % Members | |
81 | % --------------------------------------------------------------------------- | |
e79848ac GL |
82 | \latexignore{\rtfignore{\wxheading{Members}}} |
83 | ||
84 | \membersection{wxSocketBase::wxSocketBase} | |
42ff6409 | 85 | |
e79848ac GL |
86 | \func{}{wxSocketBase}{\void} |
87 | ||
407f3681 | 88 | Default constructor. Don't use it; use \helpref{wxSocketClient}{wxsocketclient} |
e79848ac GL |
89 | or \helpref{wxSocketServer}{wxsocketserver}. |
90 | ||
91 | \membersection{wxSocketBase::\destruct{wxSocketBase}} | |
92 | ||
93 | \func{}{\destruct{wxSocketBase}}{\void} | |
94 | ||
95 | Destroys the wxSocketBase object. | |
96 | ||
97 | % --------------------------------------------------------------------------- | |
98 | % State functions | |
99 | % --------------------------------------------------------------------------- | |
100 | ||
5a96d2f4 GL |
101 | % |
102 | % SetFlags | |
103 | % | |
104 | ||
105 | \membersection{wxSocketBase::SetFlags}\label{wxsocketbasesetflags} | |
106 | ||
107 | \func{void}{SetFlags}{\param{wxSocketBase::wxSockFlags}{ flags}} | |
108 | ||
109 | \twocolwidtha{7cm} | |
110 | \begin{twocollist}\itemsep=0pt | |
cf85cb95 GRG |
111 | \twocolitem{{\bf wxSOCKET\_NONE}}{Normal functionnality.} |
112 | \twocolitem{{\bf wxSOCKET\_NOWAIT}}{Get the available data in the input queue and return immediately.} | |
113 | \twocolitem{{\bf wxSOCKET\_WAITALL}}{Wait for all required data unless an error occurs.} | |
407f3681 | 114 | \twocolitem{{\bf wxSOCKET\_BLOCK}}{Block the GUI (do not wxYield) while reading/writing data.} |
5a96d2f4 GL |
115 | \end{twocollist} |
116 | ||
cf85cb95 GRG |
117 | A brief overview on how to use these flags follows. |
118 | ||
119 | If no flag is specified (this is the same as {\bf wxSOCKET\_NONE}), | |
120 | IO calls will return after some data has been read or written, even | |
121 | when the transfer might not be complete. This is the same as issuing | |
122 | exactly one blocking low-level call to recv() or send(). Note that | |
123 | blocking here refers to when the function returns, not to whether | |
124 | the GUI blocks during this time. | |
125 | ||
126 | If {\bf wxSOCKET\_NOWAIT} is specified, IO calls will return immediately. | |
127 | Read operations will retrieve only available data. Write operations will | |
128 | write as much data as possible, depending on how much space is available | |
129 | in the output buffer. This is the same as issuing exactly one nonblocking | |
130 | low-level call to recv() or send(). Note that nonblocking here refers to | |
131 | when the function returns, not to whether the GUI blocks during this time. | |
132 | ||
133 | If {\bf wxSOCKET\_WAITALL} is specified, IO calls won't return until ALL | |
134 | the data has been read or written (or until an error occurs), blocking if | |
135 | necessary, and issuing several low level calls if necessary. This is the | |
136 | same as having a loop which makes as many blocking low-level calls to | |
137 | recv() or send() as needed so as to transfer all the data. Note that | |
138 | "blocking" here refers to when the function returns, not to whether | |
139 | the GUI blocks during this time. | |
140 | ||
141 | The {\bf wxSOCKET\_BLOCK} controls whether the GUI blocks during IO | |
142 | operations. If this flag is not used, then the application must take | |
143 | extra care to avoid unwanted reentrance. | |
144 | ||
145 | So: | |
146 | ||
147 | {\bf wxSOCKET\_NONE} will try to read SOME data, no matter how much. | |
407f3681 | 148 | |
cf85cb95 GRG |
149 | {\bf wxSOCKET\_NOWAIT} will always return immediately, even if it cannot |
150 | read or write ANY data. | |
407f3681 | 151 | |
cf85cb95 GRG |
152 | {\bf wxSOCKET\_WAITALL} will only return when it has read or written ALL |
153 | the data. | |
407f3681 | 154 | |
cf85cb95 GRG |
155 | {\bf wxSOCKET\_BLOCK} has nothing to do with the previous flags and |
156 | it control whether the GUI blocks. | |
157 | ||
5a96d2f4 GL |
158 | % |
159 | % SetNotify | |
160 | % | |
161 | \membersection{wxSocketBase::SetNotify}\label{wxsocketbasesetnotify} | |
162 | ||
cf85cb95 | 163 | \func{void}{SetNotify}{\param{wxSocketEventFlags}{ flags}} |
5a96d2f4 | 164 | |
cf85cb95 GRG |
165 | SetNotify specifies which socket events are to be sent to the event handler. |
166 | The {\it flags} parameter is a combination of flags ORed toghether. The | |
167 | following flags can be used: | |
aa6d9706 GL |
168 | |
169 | \twocolwidtha{7cm} | |
170 | \begin{twocollist}\itemsep=0pt | |
cf85cb95 GRG |
171 | \twocolitem{{\bf wxSOCKET\_INPUT\_FLAG}}{to receive wxSOCKET\_INPUT} |
172 | \twocolitem{{\bf wxSOCKET\_OUTPUT\_FLAG}}{to receive wxSOCKET\_OUTPUT} | |
173 | \twocolitem{{\bf wxSOCKET\_CONNECTION\_FLAG}}{to receive wxSOCKET\_CONNECTION} | |
174 | \twocolitem{{\bf wxSOCKET\_LOST\_FLAG}}{to receive wxSOCKET\_LOST} | |
aa6d9706 GL |
175 | \end{twocollist}% |
176 | ||
177 | For example: | |
407f3681 | 178 | |
aa6d9706 | 179 | \begin{verbatim} |
cf85cb95 | 180 | sock.SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG); |
aa6d9706 | 181 | \end{verbatim} |
407f3681 | 182 | |
cf85cb95 GRG |
183 | In this example, the user will be notified about incoming socket data and |
184 | whenever the connection is closed. | |
aa6d9706 | 185 | |
7e9a386e | 186 | For more information on socket events see \helpref{wxSocket events}{wxsocketbase}. |
aa6d9706 GL |
187 | |
188 | % | |
189 | % SetTimeout | |
190 | % | |
191 | \membersection{wxSocketBase::SetTimeout}{wxsocketbasesettimeout} | |
7e9a386e | 192 | |
aa6d9706 GL |
193 | \func{void}{SetTimeout}{\param{int }{seconds}} |
194 | ||
cf85cb95 GRG |
195 | This function sets the default socket timeout in seconds. This |
196 | timeout applies to IO calls and also to Wait functions if you | |
197 | don't specify a wait interval. If you never use SetTimeout, the | |
198 | default timeout will be 10 minutes. | |
5a96d2f4 GL |
199 | |
200 | % | |
201 | % Notify | |
202 | % | |
d7cb14ce | 203 | \membersection{wxSocketBase::Notify}\label{wxsocketbasenotify} |
5a96d2f4 GL |
204 | |
205 | \func{void}{Notify}{\param{bool}{ notify}} | |
206 | ||
207 | Notify will enable (notify is TRUE) or disable (notify is FALSE) the propagation | |
208 | of socket events. | |
209 | ||
210 | % | |
211 | % Ok | |
212 | % | |
213 | ||
e79848ac GL |
214 | \membersection{wxSocketBase::Ok}\label{wxsocketbaseok} |
215 | ||
216 | \constfunc{bool}{Ok}{\void} | |
217 | ||
218 | Returns TRUE if the socket is initialized and ready and FALSE in other | |
219 | cases. | |
220 | ||
221 | \membersection{wxSocketBase::Error}\label{wxsocketbaseerror} | |
222 | ||
223 | \constfunc{bool}{Error}{\void} | |
224 | ||
cf85cb95 GRG |
225 | Returns TRUE if an error occured in the last IO operation. |
226 | ||
227 | The following operations update the Error() status: | |
228 | Read, Write, ReadMsg, WriteMsg, Peek, Unread, Discard. | |
e79848ac GL |
229 | |
230 | \membersection{wxSocketBase::IsConnected}\label{wxsocketbaseconnected} | |
231 | ||
232 | \constfunc{bool}{IsConnected}{\void} | |
233 | ||
234 | Returns TRUE if the socket is connected. | |
235 | ||
42ff6409 | 236 | \membersection{wxSocketBase::IsData}\label{wxsocketbaseisdata} |
e79848ac GL |
237 | |
238 | \constfunc{bool}{IsData}{\void} | |
239 | ||
cf85cb95 | 240 | Returns TRUE if there is data available to be read. |
e79848ac GL |
241 | |
242 | \membersection{wxSocketBase::IsDisconnected}\label{wxsocketbasedisconnected} | |
243 | ||
244 | \constfunc{bool}{IsDisconnected}{\void} | |
245 | ||
246 | Returns TRUE if the socket is disconnected. | |
247 | ||
248 | \membersection{wxSocketBase::IsNoWait}\label{wxsocketbasenowait} | |
249 | ||
250 | \constfunc{bool}{IsNoWait}{\void} | |
251 | ||
252 | Returns TRUE if the socket mustn't wait. | |
253 | ||
254 | \membersection{wxSocketBase::LastCount}\label{wxsocketbaselastcount} | |
255 | ||
aa6d9706 | 256 | \constfunc{wxUint32}{LastCount}{\void} |
e79848ac GL |
257 | |
258 | Returns the number of bytes read or written by the last IO call. | |
259 | ||
cf85cb95 GRG |
260 | The following operations update the LastCount() value: |
261 | Read, Write, ReadMsg, WriteMsg, Peek, Unread, Discard. | |
262 | ||
e79848ac GL |
263 | \membersection{wxSocketBase::LastError}\label{wxsocketbaselasterror} |
264 | ||
aa6d9706 | 265 | \constfunc{wxSocketError}{LastError}{\void} |
e79848ac | 266 | |
cf85cb95 GRG |
267 | Returns the last wxSocket error. See \helpref{wxSocket errors}{wxsocketbase}. |
268 | ||
269 | Please note that this function merely returns the last error code, | |
270 | but it should not be used to determine if an error has occured (this | |
271 | is because successful operations do not change tha LastError value). | |
272 | Use Error, instead of LastError, to determine if the last IO call | |
273 | failed. If Error returns TRUE, use LastError to discover the | |
274 | cause of the error. | |
e79848ac GL |
275 | |
276 | % --------------------------------------------------------------------------- | |
277 | % IO calls | |
278 | % --------------------------------------------------------------------------- | |
e79848ac GL |
279 | % |
280 | % Peek | |
281 | % | |
e79848ac GL |
282 | \membersection{wxSocketBase::Peek}\label{wxsocketbasepeek} |
283 | ||
aa6d9706 | 284 | \func{wxSocketBase\&}{Peek}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}} |
e79848ac GL |
285 | |
286 | This function peeks a buffer of {\it nbytes} bytes from the socket. Peeking a buffer | |
287 | doesn't delete it from the system socket in-queue. | |
288 | ||
cf85cb95 GRG |
289 | Use LastCount to verify the number of bytes actually peeked. |
290 | ||
291 | Use Error to determine if the operation succeeded. | |
292 | ||
e79848ac GL |
293 | \wxheading{Parameters} |
294 | ||
295 | \docparam{buffer}{Buffer where to put peeked data.} | |
42ff6409 | 296 | |
e79848ac GL |
297 | \docparam{nbytes}{Number of bytes.} |
298 | ||
42ff6409 JS |
299 | \wxheading{Return value} |
300 | ||
e79848ac GL |
301 | Returns a reference to the current object. |
302 | ||
cf85cb95 GRG |
303 | \wxheading{Remark/Warning} |
304 | ||
305 | The exact behaviour of wxSocketBase::Peek() depends on the combination | |
306 | of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags} | |
307 | ||
e79848ac GL |
308 | \wxheading{See also} |
309 | ||
407f3681 JS |
310 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}, |
311 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}, | |
312 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, | |
cf85cb95 | 313 | \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags} |
e79848ac GL |
314 | |
315 | % | |
316 | % Read | |
317 | % | |
e79848ac GL |
318 | \membersection{wxSocketBase::Read}\label{wxsocketbaseread} |
319 | ||
aa6d9706 | 320 | \func{wxSocketBase\&}{Read}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}} |
e79848ac GL |
321 | |
322 | This function reads a buffer of {\it nbytes} bytes from the socket. | |
323 | ||
cf85cb95 GRG |
324 | Use LastCount to verify the number of bytes actually read. |
325 | ||
326 | Use Error to determine if the operation succeeded. | |
327 | ||
e79848ac GL |
328 | \wxheading{Parameters} |
329 | ||
330 | \docparam{buffer}{Buffer where to put read data.} | |
42ff6409 | 331 | |
e79848ac GL |
332 | \docparam{nbytes}{Number of bytes.} |
333 | ||
42ff6409 JS |
334 | \wxheading{Return value} |
335 | ||
e79848ac GL |
336 | Returns a reference to the current object. |
337 | ||
9f3430a6 GL |
338 | \wxheading{Remark/Warning} |
339 | ||
cf85cb95 | 340 | The exact behaviour of wxSocketBase::Read() depends on the combination |
407f3681 | 341 | of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}. |
9f3430a6 | 342 | |
e79848ac GL |
343 | \wxheading{See also} |
344 | ||
407f3681 JS |
345 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}, |
346 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}, | |
347 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, | |
cf85cb95 | 348 | \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags} |
42ff6409 | 349 | |
e79848ac | 350 | % |
5a96d2f4 | 351 | % Write |
e79848ac | 352 | % |
e79848ac GL |
353 | \membersection{wxSocketBase::Write}\label{wxsocketbasewrite} |
354 | ||
aa6d9706 | 355 | \func{wxSocketBase\&}{Write}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}} |
e79848ac | 356 | |
cf85cb95 | 357 | This function writes a buffer of {\it nbytes} bytes to the socket. |
e79848ac | 358 | |
cf85cb95 | 359 | Use LastCount to verify the number of bytes actually written. |
9f3430a6 | 360 | |
cf85cb95 | 361 | Use Error to determine if the operation succeeded. |
9f3430a6 | 362 | |
e79848ac GL |
363 | \wxheading{Parameters} |
364 | ||
cf85cb95 | 365 | \docparam{buffer}{Buffer with the data to be sent.} |
42ff6409 | 366 | |
e79848ac GL |
367 | \docparam{nbytes}{Number of bytes.} |
368 | ||
42ff6409 JS |
369 | \wxheading{Return value} |
370 | ||
e79848ac GL |
371 | Returns a reference to the current object. |
372 | ||
cf85cb95 GRG |
373 | \wxheading{Remark/Warning} |
374 | ||
375 | The exact behaviour of wxSocketBase::Write() depends on the combination | |
407f3681 | 376 | of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}. |
cf85cb95 | 377 | |
e79848ac GL |
378 | \wxheading{See also} |
379 | ||
407f3681 JS |
380 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}, |
381 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}, | |
382 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, | |
cf85cb95 | 383 | \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags} |
e79848ac GL |
384 | |
385 | % | |
386 | % WriteMsg | |
387 | % | |
e79848ac GL |
388 | \membersection{wxSocketBase::WriteMsg}\label{wxsocketbasewritemsg} |
389 | ||
aa6d9706 | 390 | \func{wxSocketBase\&}{WriteMsg}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}} |
e79848ac | 391 | |
cf85cb95 | 392 | This function writes a buffer of {\it nbytes} bytes from the socket, but it |
e79848ac | 393 | writes a short header before so that ReadMsg can alloc the right size for |
cf85cb95 GRG |
394 | the buffer. So, a buffer sent with WriteMsg {\bf must} be read with ReadMsg. |
395 | This function always waits for the entire buffer to be sent, unless an | |
396 | error occurs. | |
397 | ||
398 | Use LastCount to verify the number of bytes actually written. | |
399 | ||
400 | Use Error to determine if the operation succeeded. | |
e79848ac GL |
401 | |
402 | \wxheading{Parameters} | |
403 | ||
cf85cb95 | 404 | \docparam{buffer}{Buffer with the data to be sent.} |
42ff6409 | 405 | |
e79848ac GL |
406 | \docparam{nbytes}{Number of bytes.} |
407 | ||
42ff6409 JS |
408 | \wxheading{Return value} |
409 | ||
e79848ac GL |
410 | Returns a reference to the current object. |
411 | ||
cf85cb95 GRG |
412 | \wxheading{Remark/Warning} |
413 | ||
414 | wxSocketBase::WriteMsg() will behave as if the wxSOCKET_WAITALL flag was always set | |
415 | and it will always ignore the wxSOCKET_NOWAIT flag. The exact behaviour of WriteMsg | |
416 | depends on the wxSOCKET_BLOCK flag. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}. | |
417 | ||
e79848ac GL |
418 | \wxheading{See also} |
419 | ||
407f3681 JS |
420 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}, |
421 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}, | |
422 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, | |
423 | \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}, | |
9f3430a6 | 424 | \helpref{wxSocketBase::ReadMsg}{wxsocketbasereadmsg} |
e79848ac GL |
425 | |
426 | % | |
427 | % ReadMsg | |
428 | % | |
e79848ac GL |
429 | \membersection{wxSocketBase::ReadMsg}\label{wxsocketbasereadmsg} |
430 | ||
aa6d9706 | 431 | \func{wxSocketBase\&}{ReadMsg}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}} |
e79848ac GL |
432 | |
433 | This function reads a buffer sent by WriteMsg on a socket. If the buffer passed | |
cf85cb95 GRG |
434 | to the function isn't big enough, the remaining bytes will be discarded. This |
435 | function always waits for the buffer to be entirely filled, unless an error occurs. | |
436 | ||
437 | Use LastCount to verify the number of bytes actually read. | |
438 | ||
439 | Use Error to determine if the operation succeeded. | |
e79848ac GL |
440 | |
441 | \wxheading{Parameters} | |
442 | ||
443 | \docparam{buffer}{Buffer where to put read data.} | |
42ff6409 | 444 | |
e79848ac GL |
445 | \docparam{nbytes}{Number of bytes allocated for the buffer.} |
446 | ||
42ff6409 JS |
447 | \wxheading{Return value} |
448 | ||
e79848ac GL |
449 | Returns a reference to the current object. |
450 | ||
cf85cb95 GRG |
451 | \wxheading{Remark/Warning} |
452 | ||
453 | wxSocketBase::ReadMsg() will behave as if the wxSOCKET_WAITALL flag was always set | |
454 | and it will always ignore the wxSOCKET_NOWAIT flag. The exact behaviour of ReadMsg | |
455 | depends on the wxSOCKET_SPEED flag. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}. | |
456 | ||
e79848ac GL |
457 | \wxheading{See also} |
458 | ||
407f3681 JS |
459 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}, |
460 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}, | |
461 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, | |
462 | \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}, | |
9f3430a6 | 463 | \helpref{wxSocketBase::WriteMsg}{wxsocketbasewritemsg} |
e79848ac GL |
464 | |
465 | % | |
466 | % Unread | |
467 | % | |
09eea162 | 468 | \membersection{wxSocketBase::Unread}\label{wxsocketbaseunread} |
e79848ac | 469 | |
aa6d9706 | 470 | \func{wxSocketBase\&}{Unread}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}} |
e79848ac | 471 | |
cf85cb95 GRG |
472 | This function unreads a buffer. That is, the data in the buffer is put back |
473 | in the incoming queue. This function is not affected by wxSocket flags. | |
474 | ||
475 | If you use LastCount, it will always return {\it nbytes}. | |
476 | ||
477 | If you use Error, it will always return FALSE. | |
e79848ac GL |
478 | |
479 | \wxheading{Parameters} | |
480 | ||
481 | \docparam{buffer}{Buffer to be unread.} | |
42ff6409 | 482 | |
e79848ac GL |
483 | \docparam{nbytes}{Number of bytes.} |
484 | ||
42ff6409 JS |
485 | \wxheading{Return value} |
486 | ||
e79848ac GL |
487 | Returns a reference to the current object. |
488 | ||
489 | \wxheading{See also} | |
490 | ||
407f3681 JS |
491 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}, |
492 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, | |
9f3430a6 | 493 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror} |
e79848ac GL |
494 | |
495 | % | |
496 | % Discard | |
497 | % | |
e79848ac GL |
498 | \membersection{wxSocketBase::Discard}\label{wxsocketbasediscard} |
499 | ||
500 | \func{wxSocketBase\&}{Discard}{\void} | |
501 | ||
502 | This function simply deletes all bytes in the incoming queue. This function | |
407f3681 JS |
503 | doesn't wait. That is, it will behave as if the wxSOCKET\_NOWAIT flag was set. The |
504 | wxSOCKET\_SPEED and wxSOCKET\_WAITALL flags have no effect on this function. | |
cf85cb95 GRG |
505 | |
506 | Use LastCount to see the number of bytes discarded. | |
507 | ||
508 | If you use Error, it will always return FALSE. | |
e79848ac GL |
509 | |
510 | % --------------------------------------------------------------------------- | |
511 | % Wait functions | |
512 | % --------------------------------------------------------------------------- | |
513 | \membersection{wxSocketBase::Wait}\label{wxsocketbasewait} | |
42ff6409 | 514 | |
aa6d9706 | 515 | \func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}} |
e79848ac | 516 | |
cf85cb95 GRG |
517 | This function waits until one of the following conditions is true: there |
518 | is data available for reading; the output buffer is empty (you can send | |
519 | new data); the connection has been lost; an incoming connection arrived | |
520 | (only for servers); a connection request has completed (only for clients). | |
e79848ac GL |
521 | |
522 | \wxheading{Parameters} | |
523 | ||
cf85cb95 | 524 | \docparam{seconds}{Number of seconds to wait. If -1, it will wait for the default timeout set with SetTimeout.} |
42ff6409 | 525 | |
aa6d9706 | 526 | \docparam{millisecond}{Number of milliseconds to wait.} |
e79848ac | 527 | |
42ff6409 | 528 | \wxheading{Return value} |
e79848ac GL |
529 | |
530 | Returns TRUE if an event occured, FALSE if the timeout was reached. | |
531 | ||
532 | \wxheading{See also} | |
533 | ||
407f3681 JS |
534 | \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread}, |
535 | \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}, | |
9f3430a6 | 536 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} |
e79848ac GL |
537 | |
538 | % | |
539 | % WaitForRead | |
540 | % | |
e79848ac | 541 | \membersection{wxSocketBase::WaitForRead}\label{wxsocketbasewaitforread} |
42ff6409 | 542 | |
aa6d9706 | 543 | \func{bool}{WaitForRead}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}} |
e79848ac | 544 | |
cf85cb95 | 545 | This function waits until there is data available to be read. |
e79848ac GL |
546 | |
547 | \wxheading{Parameters} | |
548 | ||
cf85cb95 | 549 | \docparam{seconds}{Number of seconds to wait. If -1, it will wait for the default timeout set with SetTimeout.} |
42ff6409 | 550 | |
aa6d9706 | 551 | \docparam{millisecond}{Number of milliseconds to wait.} |
e79848ac | 552 | |
42ff6409 | 553 | \wxheading{Return value} |
e79848ac | 554 | |
cf85cb95 | 555 | Returns TRUE if there is data to be read, FALSE if the timeout was reached. |
e79848ac GL |
556 | |
557 | \wxheading{See also} | |
558 | ||
407f3681 JS |
559 | \helpref{wxSocketBase::Wait}{wxsocketbasewait}, |
560 | \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}, | |
9f3430a6 | 561 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} |
e79848ac GL |
562 | |
563 | % | |
564 | % WaitForWrite | |
565 | % | |
e79848ac | 566 | \membersection{wxSocketBase::WaitForWrite}\label{wxsocketbasewaitforwrite} |
42ff6409 | 567 | |
aa6d9706 | 568 | \func{bool}{WaitForWrite}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}} |
e79848ac | 569 | |
cf85cb95 | 570 | This function waits until you can write to the socket. |
e79848ac GL |
571 | |
572 | \wxheading{Parameters} | |
573 | ||
cf85cb95 | 574 | \docparam{seconds}{Number of seconds to wait. If -1, it will wait for the default timeout set with SetTimeout.} |
42ff6409 | 575 | |
aa6d9706 | 576 | \docparam{millisecond}{Number of milliseconds to wait.} |
e79848ac | 577 | |
42ff6409 | 578 | \wxheading{Return value} |
e79848ac | 579 | |
cf85cb95 | 580 | Returns TRUE if you can write to the socket, FALSE if the timeout was reached. |
e79848ac GL |
581 | |
582 | \wxheading{See also} | |
583 | ||
407f3681 JS |
584 | \helpref{wxSocketBase::Wait}{wxsocketbasewait}, |
585 | \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread}, | |
9f3430a6 | 586 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} |
e79848ac GL |
587 | |
588 | % | |
589 | % WaitForLost | |
590 | % | |
e79848ac | 591 | \membersection{wxSocketBase::WaitForLost}\label{wxsocketbasewaitforlost} |
42ff6409 | 592 | |
aa6d9706 | 593 | \func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}} |
e79848ac | 594 | |
cf85cb95 GRG |
595 | This function waits until the connection is lost. This may happen if the |
596 | peer closes the connection or if the connection breaks. | |
e79848ac GL |
597 | |
598 | \wxheading{Parameters} | |
599 | ||
cf85cb95 | 600 | \docparam{seconds}{Number of seconds to wait. If -1, it will wait for the default timeout set with SetTimeout.} |
42ff6409 | 601 | |
aa6d9706 | 602 | \docparam{millisecond}{Number of milliseconds to wait.} |
e79848ac | 603 | |
42ff6409 | 604 | \wxheading{Return value} |
e79848ac | 605 | |
cf85cb95 | 606 | Returns TRUE if the connection was lost, FALSE if the timeout was reached. |
e79848ac GL |
607 | |
608 | \wxheading{See also} | |
609 | ||
407f3681 JS |
610 | \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread}, |
611 | \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}, | |
9f3430a6 | 612 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} |
42ff6409 | 613 | |
cf85cb95 GRG |
614 | % --------------------------------------------------------------------------- |
615 | % Socket state | |
616 | % --------------------------------------------------------------------------- | |
617 | ||
42ff6409 JS |
618 | % |
619 | % RestoreState | |
620 | % | |
621 | \membersection{wxSocketBase::RestoreState}\label{wxsocketbaserestorestate} | |
622 | ||
623 | \func{void}{RestoreState}{\void} | |
624 | ||
cf85cb95 GRG |
625 | This function restores the previous state of the socket, as saved |
626 | with SaveState. | |
627 | ||
628 | Calls to SaveState / RestoreState can be nested. | |
42ff6409 JS |
629 | |
630 | \wxheading{See also} | |
631 | ||
632 | \helpref{wxSocketBase::SaveState}{wxsocketbasesavestate} | |
e79848ac | 633 | |
e79848ac GL |
634 | % |
635 | % SaveState | |
636 | % | |
637 | \membersection{wxSocketBase::SaveState}\label{wxsocketbasesavestate} | |
42ff6409 | 638 | |
e79848ac GL |
639 | \func{void}{SaveState}{\void} |
640 | ||
641 | This function saves the current state of the socket object in a stack: | |
cf85cb95 GRG |
642 | actually it saves all flags (those set with SetFlags, SetNotify, Notfy) |
643 | and the state of the asynchronous callbacks (Callback, CallbackData). | |
644 | ||
645 | Calls to SaveState / RestoreState can be nested. | |
e79848ac GL |
646 | |
647 | \wxheading{See also} | |
648 | ||
649 | \helpref{wxSocketBase::RestoreState}{wxsocketbaserestorestate} | |
aa6d9706 GL |
650 | |
651 | % | |
652 | % GetLocal | |
653 | % | |
654 | \membersection{wxSocketBase::GetLocal}{wxsocketbasegetlocal} | |
7e9a386e | 655 | |
aa6d9706 GL |
656 | \constfunc{bool}{GetLocal}{\param{wxSockAddress\& }{addr_man}} |
657 | ||
658 | This function returns the local address field of the socket. The local | |
659 | address field contains the complete local address of the socket (local | |
660 | address, local port, ...). | |
661 | ||
662 | \wxheading{Return value} | |
663 | ||
664 | It returns TRUE if no errors happened, FALSE otherwise. | |
665 | ||
666 | % | |
667 | % GetPeer | |
668 | % | |
669 | \membersection{wxSocketBase::GetPeer}{wxsocketbasegetlocal} | |
7e9a386e | 670 | |
aa6d9706 GL |
671 | \constfunc{bool}{GetPeer}{\param{wxSockAddress\& }{addr_man}} |
672 | ||
673 | This function returns the peer address field of the socket. The peer | |
674 | address field contains the complete peer host address of the socket | |
675 | (address, port, ...). | |
676 | ||
677 | \wxheading{Return value} | |
678 | ||
679 | It returns TRUE if no errors happened, FALSE otherwise. | |
e79848ac | 680 | |
e79848ac GL |
681 | % --------------------------------------------------------------------------- |
682 | % Socket callbacks | |
683 | % --------------------------------------------------------------------------- | |
42ff6409 | 684 | \membersection{wxSocketBase::SetEventHandler}\label{wxsocketbaseseteventhandler} |
e79848ac | 685 | |
e79848ac GL |
686 | \func{void}{SetEventHandler}{\param{wxEvtHandler\&}{ evt\_hdlr}, \param{int}{ id = -1}} |
687 | ||
cf85cb95 GRG |
688 | Sets an event handler to be called when a socket event occurs. The handler |
689 | will be called for those events for which notification is enabled with | |
690 | SetNotify and Notify. | |
691 | ||
692 | You can also specify a C callback to be called when an event occurs. See | |
693 | Callback and CallbackData. | |
e79848ac GL |
694 | |
695 | \wxheading{Parameters} | |
696 | ||
697 | \docparam{evt\_hdlr}{Specifies the event handler you want to use.} | |
42ff6409 | 698 | |
e79848ac GL |
699 | \docparam{id}{The id of socket event.} |
700 | ||
701 | \wxheading{See also} | |
702 | ||
407f3681 JS |
703 | \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, |
704 | \helpref{wxSocketBase::Notify}{wxsocketbasenotify}, | |
705 | \helpref{wxSocketEvent}{wxsocketevent}, | |
706 | \helpref{wxEvtHandler}{wxevthandler}, | |
707 | \helpref{wxSocketBase::Callback}{wxsocketbasecallback}, | |
cf85cb95 | 708 | \helpref{wxSocketBase::CallbackData}{wxsocketbasecallbackdata} |
aa6d9706 GL |
709 | |
710 | \membersection{wxSocketBase::Callback}\label{wxsocketbasecallback} | |
711 | ||
712 | \func{wxSocketBase::wxSockCbk}{Callback}{\param{wxSocketBase::wxSockCbk}{ callback}} | |
713 | ||
cf85cb95 GRG |
714 | You can setup a C callback to be called when an event occurs. The callback |
715 | will be called only for those events for which notification has been enabled | |
716 | with Notify and SetNotify. The prototype of the callback must be as follows: | |
717 | ||
aa6d9706 GL |
718 | \begin{verbatim} |
719 | void SocketCallback(wxSocketBase& sock,wxSocketNotify evt,char *cdata); | |
720 | \end{verbatim} | |
721 | ||
cf85cb95 GRG |
722 | The first parameter is a reference to the socket object in which the event |
723 | occured. The second parameter tells you which event occured. (See \helpref{wxSocket events}{wxsocketbase}). | |
1fb3eae5 | 724 | The third parameter is the user data you specified using \helpref{CallbackData}{wxsocketbasecallbackdata}. |
aa6d9706 GL |
725 | |
726 | \wxheading{Return value} | |
727 | ||
cf85cb95 | 728 | A pointer to the previous callback. |
aa6d9706 GL |
729 | |
730 | \wxheading{See also} | |
731 | ||
407f3681 JS |
732 | \helpref{wxSocketBase::CallbackData}{wxsocketbasecallbackdata}, |
733 | \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, | |
aa6d9706 GL |
734 | \helpref{wxSocketBase::Notify}{wxsocketbasenotify} |
735 | ||
cf85cb95 | 736 | \membersection{wxSocketBase::CallbackData}\label{wxsocketbasecallbackdata} |
aa6d9706 GL |
737 | |
738 | \func{char *}{CallbackData}{\param{char *}{cdata}} | |
739 | ||
cf85cb95 | 740 | This function sets the the user data which will be passed to a \helpref{C callback}{wxsocketbasecallback}. |
aa6d9706 GL |
741 | |
742 | \wxheading{Return value} | |
743 | ||
cf85cb95 GRG |
744 | A pointer to the previous user data. |
745 | ||
407f3681 JS |
746 | \helpref{wxSocketBase::Callback}{wxsocketbasecallback}, |
747 | \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, | |
cf85cb95 | 748 | \helpref{wxSocketBase::Notify}{wxsocketbasenotify} |
e79848ac GL |
749 | |
750 | % --------------------------------------------------------------------------- | |
751 | % CLASS wxSocketClient | |
752 | % --------------------------------------------------------------------------- | |
e79848ac GL |
753 | \section{\class{wxSocketClient}}\label{wxsocketclient} |
754 | ||
755 | \wxheading{Derived from} | |
756 | ||
757 | \helpref{wxSocketBase}{wxsocketbase} | |
758 | ||
954b8ae6 JS |
759 | \wxheading{Include files} |
760 | ||
761 | <wx/socket.h> | |
762 | ||
e79848ac GL |
763 | % --------------------------------------------------------------------------- |
764 | % Members | |
765 | % --------------------------------------------------------------------------- | |
e79848ac GL |
766 | % |
767 | % wxSocketClient | |
768 | % | |
e79848ac | 769 | \membersection{wxSocketClient::wxSocketClient} |
42ff6409 | 770 | |
e79848ac GL |
771 | \func{}{wxSocketClient}{\param{wxSockFlags}{ flags = wxSocketBase::NONE}} |
772 | ||
773 | Constructs a new wxSocketClient. | |
42ff6409 | 774 | |
e79848ac GL |
775 | \wxheading{Parameters} |
776 | ||
777 | \docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})} | |
778 | ||
779 | % | |
780 | % ~wxSocketClient | |
781 | % | |
e79848ac | 782 | \membersection{wxSocketClient::\destruct{wxSocketClient}} |
42ff6409 | 783 | |
e79848ac GL |
784 | \func{}{\destruct{wxSocketClient}}{\void} |
785 | ||
aed0ed3c | 786 | Destroys a wxSocketClient object. |
e79848ac GL |
787 | |
788 | % | |
789 | % Connect | |
790 | % | |
42ff6409 | 791 | \membersection{wxSocketClient::Connect}\label{wxsocketclientconnect} |
e79848ac | 792 | |
e79848ac GL |
793 | \func{bool}{Connect}{\param{wxSockAddress\&}{ address}, \param{bool}{ wait = TRUE}} |
794 | ||
cf85cb95 GRG |
795 | Connects to a server using the specified address. |
796 | ||
797 | If {\it wait} is TRUE, Connect will wait until the connection completes and | |
798 | the socket is ready to send or receive data, or until an event occurs. | |
407f3681 | 799 | |
cf85cb95 GRG |
800 | {\bf Warning !} This will block the GUI. |
801 | ||
802 | If {\it wait} is FALSE, Connect will try to establish the connection and | |
803 | return immediately, without blocking the GUI. When used this way, even if | |
804 | Connect returns FALSE, the connection request can be completed later. | |
805 | To detect this, use WaitConnection, or watch "connection" events (for | |
407f3681 | 806 | succesful establishment) and "lost" events (for connection failure). |
e79848ac GL |
807 | |
808 | \wxheading{Parameters} | |
809 | ||
810 | \docparam{address}{Address of the server.} | |
42ff6409 | 811 | |
e79848ac GL |
812 | \docparam{wait}{If true, waits for the connection to be ready.} |
813 | ||
814 | \wxheading{Return value} | |
815 | ||
816 | Returns TRUE if the connection is established and no error occurs. | |
817 | ||
cf85cb95 GRG |
818 | If {\it wait} was TRUE, and Connect returns FALSE, an error occured |
819 | and the connection failed. | |
820 | ||
821 | If {\it wait} was FALSE, and Connect returns FALSE, you should still | |
822 | be prepared to handle the completion of this connection request, either | |
823 | with WaitOnConnect or by watching "connection" and "lost" events. | |
824 | ||
e79848ac GL |
825 | \wxheading{See also} |
826 | ||
407f3681 JS |
827 | \helpref{wxSocketClient::WaitOnConnect}{wxsocketclientwaitonconnect}, |
828 | \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, | |
cf85cb95 | 829 | \helpref{wxSocketBase::Notify}{wxsocketbasenotify} |
e79848ac GL |
830 | |
831 | % | |
832 | % WaitOnConnect | |
833 | % | |
42ff6409 | 834 | \membersection{wxSocketClient::WaitOnConnect}\label{wxsocketclientwaitonconnect} |
e79848ac | 835 | |
aa6d9706 | 836 | \func{bool}{WaitOnConnect}{\param{long}{ seconds = -1}, \param{long}{ milliseconds = 0}} |
e79848ac | 837 | |
cf85cb95 GRG |
838 | Wait until the connection is succesfully established or until it fails. |
839 | Use this function after a call to Connect with {\it wait} set to FALSE. | |
840 | ||
841 | \wxheading{Parameters} | |
842 | ||
843 | \docparam{seconds}{Number of seconds to wait. If -1, it will wait for the default timeout set with SetTimeout.} | |
844 | ||
845 | \docparam{millisecond}{Number of milliseconds to wait.} | |
846 | ||
847 | \wxheading{Return value} | |
848 | ||
849 | If the connection is succesfully established, it returns TRUE. | |
850 | ||
851 | If the timeout expires, or if the connection fails, it returns FALSE. | |
e79848ac GL |
852 | |
853 | \wxheading{See also} | |
854 | ||
cf85cb95 | 855 | \helpref{wxSocketClient::Connect}{wxsocketclientconnect} |
e79848ac GL |
856 | |
857 | % --------------------------------------------------------------------------- | |
42ff6409 | 858 | % CLASS: wxSocketEvent |
e79848ac | 859 | % --------------------------------------------------------------------------- |
42ff6409 | 860 | \section{\class{wxSocketEvent}}\label{wxsocketevent} |
e79848ac | 861 | |
42ff6409 | 862 | This event class contains information about socket events. |
e79848ac GL |
863 | |
864 | \wxheading{Derived from} | |
865 | ||
42ff6409 | 866 | \helpref{wxEvent}{wxevent} |
e79848ac | 867 | |
954b8ae6 JS |
868 | \wxheading{Include files} |
869 | ||
870 | <wx/socket.h> | |
871 | ||
42ff6409 | 872 | \wxheading{Event table macros} |
e79848ac | 873 | |
42ff6409 JS |
874 | To process a socket event, use these event handler macros to direct input to member |
875 | functions that take a wxSocketEvent argument. | |
e79848ac | 876 | |
42ff6409 JS |
877 | \twocolwidtha{7cm} |
878 | \begin{twocollist}\itemsep=0pt | |
879 | \twocolitem{{\bf EVT\_SOCKET(id, func)}}{Process a socket event, supplying the member function.} | |
880 | \end{twocollist}% | |
e79848ac | 881 | |
cf85cb95 GRG |
882 | [TODO:] |
883 | A brief note on how to use events. | |
884 | The wxSOCKET_INPUT event is generated when the | |
885 | ||
e79848ac GL |
886 | \wxheading{See also} |
887 | ||
407f3681 JS |
888 | \helpref{wxSocketBase}{wxsocketbase}, |
889 | \helpref{wxSocketClient}{wxsocketclient}, | |
42ff6409 | 890 | \helpref{wxSocketServer}{wxsocketserver} |
e79848ac | 891 | |
42ff6409 | 892 | \latexignore{\rtfignore{\wxheading{Members}}} |
e79848ac | 893 | |
42ff6409 | 894 | \membersection{wxSocketEvent::wxSocketEvent} |
e79848ac | 895 | |
42ff6409 | 896 | \func{}{wxSocketEvent}{\param{int}{ id = 0}} |
e79848ac | 897 | |
42ff6409 | 898 | Constructor. |
e79848ac | 899 | |
42ff6409 | 900 | \membersection{wxSocketEvent::SocketEvent}\label{wxsocketeventsocketevent} |
e79848ac | 901 | |
aa6d9706 | 902 | \constfunc{wxSocketNotify}{SocketEvent}{\void} |
e79848ac | 903 | |
42ff6409 | 904 | Returns the socket event type. |
e79848ac | 905 | |
42ff6409 JS |
906 | % --------------------------------------------------------------------------- |
907 | % CLASS: wxSocketServer | |
908 | % --------------------------------------------------------------------------- | |
909 | \section{\class{wxSocketServer}}\label{wxsocketserver} | |
910 | ||
911 | \wxheading{Derived from} | |
912 | ||
913 | \helpref{wxSocketBase}{wxsocketbase} | |
914 | ||
954b8ae6 JS |
915 | \wxheading{Include files} |
916 | ||
917 | <wx/socket.h> | |
918 | ||
42ff6409 JS |
919 | % --------------------------------------------------------------------------- |
920 | % Members | |
921 | % --------------------------------------------------------------------------- | |
922 | \latexignore{\rtfignore{\wxheading{Members}}} | |
923 | ||
924 | % | |
925 | % wxSocketServer | |
926 | % | |
927 | \membersection{wxSocketServer::wxSocketServer}\label{wxsocketserverconstr} | |
928 | ||
929 | \func{}{wxSocketServer}{\param{wxSockAddress\&}{ address}, \param{wxSockFlags}{ flags = wxSocketBase::NONE}} | |
930 | ||
931 | Constructs a new wxSocketServer. | |
932 | ||
42ff6409 JS |
933 | \wxheading{Parameters} |
934 | ||
935 | \docparam{address}{Specifies the local address for the server (e.g. port number).} | |
936 | ||
937 | \docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})} | |
938 | ||
939 | % | |
940 | % ~wxSocketServer | |
941 | % | |
942 | \membersection{wxSocketServer::\destruct{wxSocketServer}} | |
943 | ||
944 | \func{}{\destruct{wxSocketServer}}{\void} | |
945 | ||
cf85cb95 | 946 | Destroys a wxSocketServer object (it doesn't close the accepted connections). |
42ff6409 JS |
947 | |
948 | % | |
949 | % Accept | |
950 | % | |
1fb3eae5 | 951 | \membersection{wxSocketServer::Accept}\label{wxsocketserveraccept} |
42ff6409 | 952 | |
cf85cb95 GRG |
953 | \func{wxSocketBase *}{Accept}{\param{bool}{ wait = TRUE}} |
954 | ||
955 | Creates a new object wxSocketBase and accepts an incoming connection. | |
42ff6409 | 956 | |
cf85cb95 GRG |
957 | If {\it wait} is TRUE and there are no pending connections to be |
958 | accepted, it will wait for the next incoming connection to arrive. | |
959 | {\bf Warning !} This will block the GUI. | |
960 | ||
961 | If {\it wait} is FALSE, it will try to accept a pending connection | |
962 | if there is one, but it will always return immediately without | |
963 | blocking the GUI. If you want to use Accept in this way, you can | |
964 | either check for incoming connections with WaitForAccept or watch | |
965 | "connection" events, then call Accept once you know that there is | |
966 | an incoming connection waiting to be accepted. | |
42ff6409 JS |
967 | |
968 | \wxheading{Return value} | |
969 | ||
cf85cb95 GRG |
970 | Returns an opened socket connection, or NULL if an error occured or |
971 | if the {\it wait} parameter was FALSE and there were no pending | |
972 | connections. | |
42ff6409 JS |
973 | |
974 | \wxheading{See also} | |
975 | ||
1fb3eae5 | 976 | \helpref{wxSocketServer::WaitForAccept}{wxsocketserverwaitforaccept}, |
407f3681 JS |
977 | \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, |
978 | \helpref{wxSocketBase::Notify}{wxsocketbasenotify}, | |
42ff6409 JS |
979 | \helpref{wxSocketServer::AcceptWith}{wxsocketserveracceptwith} |
980 | ||
981 | % | |
982 | % AcceptWith | |
983 | % | |
984 | \membersection{wxSocketServer::AcceptWith}\label{wxsocketserveracceptwith} | |
985 | ||
cf85cb95 | 986 | \func{bool}{AcceptWith}{\param{wxSocketBase\&}{ socket}, \param{bool}{ wait = TRUE}} |
42ff6409 JS |
987 | |
988 | Accept an incoming connection using the specified socket object. | |
989 | This is useful when someone wants to inherit wxSocketBase. | |
990 | ||
991 | \wxheading{Parameters} | |
992 | ||
993 | \docparam{socket}{Socket to be initialized} | |
994 | ||
995 | \wxheading{Return value} | |
996 | ||
cf85cb95 GRG |
997 | Returns TRUE on success, or FALSE if an error occured or if the |
998 | {\it wait} parameter was FALSE and there were no pending | |
999 | connections. | |
1000 | ||
1fb3eae5 | 1001 | \helpref{wxSocketServer::WaitForAccept}{wxsocketserverwaitforaccept}, |
407f3681 JS |
1002 | \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, |
1003 | \helpref{wxSocketBase::Notify}{wxsocketbasenotify}, | |
1004 | \helpref{wxSocketServer::Accept}{wxsocketserveraccept} | |
cf85cb95 GRG |
1005 | |
1006 | % | |
1007 | % WaitForAccept | |
1008 | % | |
1009 | \membersection{wxSocketServer::WaitForAccept}\label{wxsocketserverwaitforaccept} | |
1010 | ||
1011 | \func{bool}{WaitForAccept}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}} | |
1012 | ||
1013 | This function waits for an incoming connection. Use it if you want to call | |
1014 | Accept or AcceptWith with {\it wait} set to FALSE, to detect when an incoming | |
1015 | connection is waiting to be accepted. | |
1016 | ||
1017 | \wxheading{Parameters} | |
1018 | ||
1019 | \docparam{seconds}{Number of seconds to wait. If -1, it will wait for the default timeout set with SetTimeout.} | |
1020 | ||
1021 | \docparam{millisecond}{Number of milliseconds to wait.} | |
1022 | ||
1023 | \wxheading{Return value} | |
1024 | ||
1025 | Returns TRUE if an incoming connection arrived, FALSE if the timeout expired. | |
1026 | ||
1027 | \wxheading{See also} | |
1028 | ||
407f3681 | 1029 | \helpref{wxSocketServer::Accept}{wxsocketserveraccept}, |
cf85cb95 GRG |
1030 | \helpref{wxSocketServer::AcceptWith}{wxsocketserveracceptwith} |
1031 |