]>
Commit | Line | Data |
---|---|---|
e79848ac GL |
1 | \section{\class{wxSocketBase}}\label{wxsocketbase} |
2 | ||
3 | \wxheading{Derived from} | |
4 | ||
5 | \helpref{wxEvtHandler}{wxevthandler} | |
6 | ||
7 | % --------------------------------------------------------------------------- | |
8 | % Event handling | |
9 | % --------------------------------------------------------------------------- | |
10 | \wxheading{Event handling} | |
11 | ||
12 | To process events from a socket, use the following event handler macro to direct | |
13 | input to member | |
14 | functions that take a \helpref{wxSocketEvent}{wxsocketevent} argument. | |
15 | ||
42ff6409 | 16 | \twocolwidtha{7cm}% |
e79848ac GL |
17 | \begin{twocollist}\itemsep=0pt |
18 | \twocolitem{{\bf EVT\_SOCKET(id, func)}}{A socket event occured.} | |
19 | \end{twocollist}% | |
20 | ||
21 | % --------------------------------------------------------------------------- | |
22 | % See also ... | |
23 | % --------------------------------------------------------------------------- | |
e79848ac GL |
24 | \wxheading{See also} |
25 | ||
9f3430a6 GL |
26 | \helpref{wxSocketEvent}{wxsocketevent}\\ |
27 | \helpref{wxSocketClient}{wxsocketclient}\\ | |
28 | \helpref{wxSocketServer}{wxsocketserver} | |
e79848ac GL |
29 | |
30 | % --------------------------------------------------------------------------- | |
31 | % Members | |
32 | % --------------------------------------------------------------------------- | |
e79848ac GL |
33 | \latexignore{\rtfignore{\wxheading{Members}}} |
34 | ||
35 | \membersection{wxSocketBase::wxSocketBase} | |
42ff6409 | 36 | |
e79848ac GL |
37 | \func{}{wxSocketBase}{\void} |
38 | ||
39 | Default constructor but don't use it, you must use \helpref{wxSocketClient}{wxsocketclient} | |
40 | or \helpref{wxSocketServer}{wxsocketserver}. | |
41 | ||
42 | \membersection{wxSocketBase::\destruct{wxSocketBase}} | |
43 | ||
44 | \func{}{\destruct{wxSocketBase}}{\void} | |
45 | ||
46 | Destroys the wxSocketBase object. | |
47 | ||
48 | % --------------------------------------------------------------------------- | |
49 | % State functions | |
50 | % --------------------------------------------------------------------------- | |
51 | ||
52 | \membersection{wxSocketBase::Ok}\label{wxsocketbaseok} | |
53 | ||
54 | \constfunc{bool}{Ok}{\void} | |
55 | ||
56 | Returns TRUE if the socket is initialized and ready and FALSE in other | |
57 | cases. | |
58 | ||
59 | \membersection{wxSocketBase::Error}\label{wxsocketbaseerror} | |
60 | ||
61 | \constfunc{bool}{Error}{\void} | |
62 | ||
63 | Returns TRUE if an error occured. | |
64 | ||
65 | \membersection{wxSocketBase::IsConnected}\label{wxsocketbaseconnected} | |
66 | ||
67 | \constfunc{bool}{IsConnected}{\void} | |
68 | ||
69 | Returns TRUE if the socket is connected. | |
70 | ||
42ff6409 | 71 | \membersection{wxSocketBase::IsData}\label{wxsocketbaseisdata} |
e79848ac GL |
72 | |
73 | \constfunc{bool}{IsData}{\void} | |
74 | ||
75 | Returns TRUE if some data is arrived on the socket. | |
76 | ||
77 | \membersection{wxSocketBase::IsDisconnected}\label{wxsocketbasedisconnected} | |
78 | ||
79 | \constfunc{bool}{IsDisconnected}{\void} | |
80 | ||
81 | Returns TRUE if the socket is disconnected. | |
82 | ||
83 | \membersection{wxSocketBase::IsNoWait}\label{wxsocketbasenowait} | |
84 | ||
85 | \constfunc{bool}{IsNoWait}{\void} | |
86 | ||
87 | Returns TRUE if the socket mustn't wait. | |
88 | ||
89 | \membersection{wxSocketBase::LastCount}\label{wxsocketbaselastcount} | |
90 | ||
91 | \constfunc{size\_t}{LastCount}{\void} | |
92 | ||
93 | Returns the number of bytes read or written by the last IO call. | |
94 | ||
95 | \membersection{wxSocketBase::LastError}\label{wxsocketbaselasterror} | |
96 | ||
97 | \constfunc{int}{LastError}{\void} | |
98 | ||
99 | Returns an error in the errno format (see your C programmer's guide). | |
100 | ||
101 | % --------------------------------------------------------------------------- | |
102 | % IO calls | |
103 | % --------------------------------------------------------------------------- | |
e79848ac GL |
104 | % |
105 | % Peek | |
106 | % | |
e79848ac GL |
107 | \membersection{wxSocketBase::Peek}\label{wxsocketbasepeek} |
108 | ||
109 | \func{wxSocketBase\&}{Peek}{\param{char *}{ buffer}, \param{size\_t}{ nbytes}} | |
110 | ||
111 | This function peeks a buffer of {\it nbytes} bytes from the socket. Peeking a buffer | |
112 | doesn't delete it from the system socket in-queue. | |
113 | ||
114 | \wxheading{Parameters} | |
115 | ||
116 | \docparam{buffer}{Buffer where to put peeked data.} | |
42ff6409 | 117 | |
e79848ac GL |
118 | \docparam{nbytes}{Number of bytes.} |
119 | ||
42ff6409 JS |
120 | \wxheading{Return value} |
121 | ||
e79848ac GL |
122 | Returns a reference to the current object. |
123 | ||
124 | \wxheading{See also} | |
125 | ||
9f3430a6 GL |
126 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ |
127 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
128 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror} | |
e79848ac GL |
129 | |
130 | % | |
131 | % Read | |
132 | % | |
e79848ac GL |
133 | \membersection{wxSocketBase::Read}\label{wxsocketbaseread} |
134 | ||
135 | \func{wxSocketBase\&}{Read}{\param{char *}{ buffer}, \param{size\_t}{ nbytes}} | |
136 | ||
137 | This function reads a buffer of {\it nbytes} bytes from the socket. | |
138 | ||
139 | \wxheading{Parameters} | |
140 | ||
141 | \docparam{buffer}{Buffer where to put read data.} | |
42ff6409 | 142 | |
e79848ac GL |
143 | \docparam{nbytes}{Number of bytes.} |
144 | ||
42ff6409 JS |
145 | \wxheading{Return value} |
146 | ||
e79848ac GL |
147 | Returns a reference to the current object. |
148 | ||
9f3430a6 GL |
149 | \wxheading{Remark/Warning} |
150 | ||
151 | By default, Read uses an internal asynchronous manager: it will send data when | |
152 | the socket requests them. It is particularly interesting when you enter a long | |
153 | data transfer (e.g. a big file, an image, ...). But it is also buggy when you | |
154 | simply discuss with the peer using user data. In this case, wxSocket prepares | |
155 | itself to send data (Write wait for them to be sent) and during a GUI refresh | |
156 | the user enters new data, which involves a new Read call though the previous | |
157 | isn't finished. Well, in most cases it can work but it might fail too. | |
158 | So I advise you to use the SPEED flag, which disables the asynchronous manager, | |
159 | when you just want to discuss with the peer. | |
160 | ||
161 | This remark is also valid for all IO call. | |
162 | ||
e79848ac GL |
163 | \wxheading{See also} |
164 | ||
42ff6409 JS |
165 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}, |
166 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, | |
167 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror} | |
e79848ac | 168 | |
42ff6409 JS |
169 | \membersection{wxSocketBase::SetFlags}\label{wxsocketbasesetflags} |
170 | ||
171 | \func{void}{SetFlags}{\param{wxSockFlags}{ flags}} | |
172 | ||
07b73270 GL |
173 | \twocolwidtha{7cm} |
174 | \begin{twocollist}\itemsep=0pt | |
175 | \twocolitem{{\bf wxSocketBase::NONE}}{Normal functionnalities.} | |
176 | \twocolitem{{\bf wxSocketBase::NOWAIT}}{Get the available data in the input queue and exit immediately.} | |
177 | \twocolitem{{\bf wxSocketBase::WAITALL}}{Wait for all required data unless an error occured.} | |
178 | \twocolitem{{\bf wxSocketBase::SPEED}}{Disable the asynchronous IO functionnality.} | |
179 | \end{twocollist} | |
42ff6409 | 180 | |
e79848ac GL |
181 | % |
182 | % Read | |
183 | % | |
e79848ac GL |
184 | \membersection{wxSocketBase::Write}\label{wxsocketbasewrite} |
185 | ||
186 | \func{wxSocketBase\&}{Write}{\param{const char *}{ buffer}, \param{size\_t}{ nbytes}} | |
187 | ||
188 | This function writes a buffer of {\it nbytes} bytes from the socket. | |
189 | ||
9f3430a6 GL |
190 | \wxheading{Remark/Warning} |
191 | ||
192 | By default, Write uses an internal asynchronous manager: it will send data when | |
193 | the socket requests them. It is particularly interesting when you enter a long | |
194 | data transfer (e.g. a big file, an image, ...). But it is also buggy when you | |
195 | simply discuss with the peer using user data. In this case, wxSocket prepares | |
196 | itself to send data (Write wait for them to be sent) and during a GUI refresh | |
197 | the user enters new data, which involves a new Write call though the previous | |
198 | isn't finished. Well, in most cases it can work but it might fail too. | |
199 | So I advise you to use the SPEED flag, which disables the asynchronous manager, | |
200 | when you just want to discuss with the peer. | |
201 | ||
e79848ac GL |
202 | \wxheading{Parameters} |
203 | ||
204 | \docparam{buffer}{Buffer where to get the data to write.} | |
42ff6409 | 205 | |
e79848ac GL |
206 | \docparam{nbytes}{Number of bytes.} |
207 | ||
42ff6409 JS |
208 | \wxheading{Return value} |
209 | ||
e79848ac GL |
210 | Returns a reference to the current object. |
211 | ||
212 | \wxheading{See also} | |
213 | ||
9f3430a6 GL |
214 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ |
215 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
216 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror} | |
e79848ac GL |
217 | |
218 | % | |
219 | % WriteMsg | |
220 | % | |
e79848ac GL |
221 | \membersection{wxSocketBase::WriteMsg}\label{wxsocketbasewritemsg} |
222 | ||
223 | \func{wxSocketBase\&}{WriteMsg}{\param{const char *}{ buffer}, \param{size\_t}{ nbytes}} | |
224 | ||
225 | This function writes a buffer of {\it nbytes} bytes from the socket. But it | |
226 | writes a short header before so that ReadMsg can alloc the right size for | |
227 | the buffer. So a buffer sent with WriteMsg {\bf must} be read with ReadMsg. | |
228 | ||
229 | \wxheading{Parameters} | |
230 | ||
231 | \docparam{buffer}{Buffer where to put data peeked.} | |
42ff6409 | 232 | |
e79848ac GL |
233 | \docparam{nbytes}{Number of bytes.} |
234 | ||
42ff6409 JS |
235 | \wxheading{Return value} |
236 | ||
e79848ac GL |
237 | Returns a reference to the current object. |
238 | ||
239 | \wxheading{See also} | |
240 | ||
9f3430a6 GL |
241 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ |
242 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
243 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}\\ | |
244 | \helpref{wxSocketBase::ReadMsg}{wxsocketbasereadmsg} | |
e79848ac GL |
245 | |
246 | % | |
247 | % ReadMsg | |
248 | % | |
e79848ac GL |
249 | \membersection{wxSocketBase::ReadMsg}\label{wxsocketbasereadmsg} |
250 | ||
251 | \func{wxSocketBase\&}{ReadMsg}{\param{char *}{ buffer}, \param{size\_t}{ nbytes}} | |
252 | ||
253 | This function reads a buffer sent by WriteMsg on a socket. If the buffer passed | |
254 | to the function isn't big enough, the function filled it and then discard the | |
255 | bytes left. This function always wait for the buffer to be entirely filled. | |
256 | ||
257 | \wxheading{Parameters} | |
258 | ||
259 | \docparam{buffer}{Buffer where to put read data.} | |
42ff6409 | 260 | |
e79848ac GL |
261 | \docparam{nbytes}{Number of bytes allocated for the buffer.} |
262 | ||
42ff6409 JS |
263 | \wxheading{Return value} |
264 | ||
e79848ac GL |
265 | Returns a reference to the current object. |
266 | ||
267 | \wxheading{See also} | |
268 | ||
9f3430a6 GL |
269 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ |
270 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
271 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}\\ | |
272 | \helpref{wxSocketBase::WriteMsg}{wxsocketbasewritemsg} | |
e79848ac GL |
273 | |
274 | % | |
275 | % Unread | |
276 | % | |
e79848ac GL |
277 | \membersection{wxSocketBase::UnRead}\label{wxsocketbaseunread} |
278 | ||
279 | \func{wxSocketBase\&}{UnRead}{\param{const char *}{ buffer}, \param{size\_t}{ nbytes}} | |
280 | ||
281 | This function unreads a buffer. It means that the buffer is put in the top | |
282 | of the incoming queue. But, it is put also at the end of all unread buffers. | |
283 | It is useful for sockets because we can't seek it. | |
284 | ||
285 | \wxheading{Parameters} | |
286 | ||
287 | \docparam{buffer}{Buffer to be unread.} | |
42ff6409 | 288 | |
e79848ac GL |
289 | \docparam{nbytes}{Number of bytes.} |
290 | ||
42ff6409 JS |
291 | \wxheading{Return value} |
292 | ||
e79848ac GL |
293 | Returns a reference to the current object. |
294 | ||
295 | \wxheading{See also} | |
296 | ||
9f3430a6 GL |
297 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ |
298 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
299 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror} | |
e79848ac GL |
300 | |
301 | % | |
302 | % Discard | |
303 | % | |
e79848ac GL |
304 | \membersection{wxSocketBase::Discard}\label{wxsocketbasediscard} |
305 | ||
306 | \func{wxSocketBase\&}{Discard}{\void} | |
307 | ||
308 | This function simply deletes all bytes in the incoming queue. This function | |
309 | doesn't wait. | |
310 | ||
311 | % --------------------------------------------------------------------------- | |
312 | % Wait functions | |
313 | % --------------------------------------------------------------------------- | |
314 | \membersection{wxSocketBase::Wait}\label{wxsocketbasewait} | |
42ff6409 | 315 | |
e79848ac GL |
316 | \func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ microsecond = 0}} |
317 | ||
318 | This function waits for an event: it could be an incoming byte, the possibility | |
319 | for the client to write, a lost connection, an incoming connection, an | |
320 | established connection. | |
321 | ||
322 | \wxheading{Parameters} | |
323 | ||
324 | \docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.} | |
42ff6409 | 325 | |
e79848ac GL |
326 | \docparam{microsecond}{Number of microseconds to wait.} |
327 | ||
42ff6409 | 328 | \wxheading{Return value} |
e79848ac GL |
329 | |
330 | Returns TRUE if an event occured, FALSE if the timeout was reached. | |
331 | ||
332 | \wxheading{See also} | |
333 | ||
9f3430a6 GL |
334 | \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread}\\ |
335 | \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}\\ | |
336 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} | |
e79848ac GL |
337 | |
338 | % | |
339 | % WaitForRead | |
340 | % | |
e79848ac | 341 | \membersection{wxSocketBase::WaitForRead}\label{wxsocketbasewaitforread} |
42ff6409 | 342 | |
e79848ac GL |
343 | \func{bool}{WaitForRead}{\param{long}{ seconds = -1}, \param{long}{ microsecond = 0}} |
344 | ||
345 | This function waits for a read event. | |
346 | ||
347 | \wxheading{Parameters} | |
348 | ||
349 | \docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.} | |
42ff6409 | 350 | |
e79848ac GL |
351 | \docparam{microsecond}{Number of microseconds to wait.} |
352 | ||
42ff6409 | 353 | \wxheading{Return value} |
e79848ac GL |
354 | |
355 | Returns TRUE if a byte arrived, FALSE if the timeout was reached. | |
356 | ||
357 | \wxheading{See also} | |
358 | ||
9f3430a6 GL |
359 | \helpref{wxSocketBase::Wait}{wxsocketbasewait}\\ |
360 | \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}\\ | |
361 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} | |
e79848ac GL |
362 | |
363 | % | |
364 | % WaitForWrite | |
365 | % | |
e79848ac | 366 | \membersection{wxSocketBase::WaitForWrite}\label{wxsocketbasewaitforwrite} |
42ff6409 | 367 | |
e79848ac GL |
368 | \func{bool}{WaitForWrite}{\param{long}{ seconds = -1}, \param{long}{ microsecond = 0}} |
369 | ||
370 | This function waits for a write event. | |
371 | ||
372 | \wxheading{Parameters} | |
373 | ||
374 | \docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.} | |
42ff6409 | 375 | |
e79848ac GL |
376 | \docparam{microsecond}{Number of microseconds to wait.} |
377 | ||
42ff6409 | 378 | \wxheading{Return value} |
e79848ac GL |
379 | |
380 | Returns TRUE if a write event occured, FALSE if the timeout was reached. | |
381 | ||
382 | \wxheading{See also} | |
383 | ||
9f3430a6 GL |
384 | \helpref{wxSocketBase::Wait}{wxsocketbasewait}\\ |
385 | \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread}\\ | |
386 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} | |
e79848ac GL |
387 | |
388 | % | |
389 | % WaitForLost | |
390 | % | |
e79848ac | 391 | \membersection{wxSocketBase::WaitForLost}\label{wxsocketbasewaitforlost} |
42ff6409 | 392 | |
e79848ac GL |
393 | \func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ microsecond = 0}} |
394 | ||
395 | This function waits for a "lost" event. For instance, the peer may have closed | |
396 | the connection, or the connection may have been broken. | |
397 | ||
398 | \wxheading{Parameters} | |
399 | ||
400 | \docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.} | |
42ff6409 | 401 | |
e79848ac GL |
402 | \docparam{microsecond}{Number of microseconds to wait.} |
403 | ||
42ff6409 | 404 | \wxheading{Return value} |
e79848ac GL |
405 | |
406 | Returns TRUE if a "lost" event occured, FALSE if the timeout was reached. | |
407 | ||
408 | \wxheading{See also} | |
409 | ||
9f3430a6 GL |
410 | \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread}\\ |
411 | \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}\\ | |
412 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} | |
42ff6409 JS |
413 | |
414 | % | |
415 | % RestoreState | |
416 | % | |
417 | \membersection{wxSocketBase::RestoreState}\label{wxsocketbaserestorestate} | |
418 | ||
419 | \func{void}{RestoreState}{\void} | |
420 | ||
421 | This function restores a previously saved state. | |
422 | ||
423 | \wxheading{See also} | |
424 | ||
425 | \helpref{wxSocketBase::SaveState}{wxsocketbasesavestate} | |
e79848ac GL |
426 | |
427 | % --------------------------------------------------------------------------- | |
428 | % Socket state | |
429 | % --------------------------------------------------------------------------- | |
e79848ac GL |
430 | % |
431 | % SaveState | |
432 | % | |
433 | \membersection{wxSocketBase::SaveState}\label{wxsocketbasesavestate} | |
42ff6409 | 434 | |
e79848ac GL |
435 | \func{void}{SaveState}{\void} |
436 | ||
437 | This function saves the current state of the socket object in a stack: | |
438 | actually it saves all flags and the state of the asynchronous callbacks. | |
439 | ||
440 | \wxheading{See also} | |
441 | ||
442 | \helpref{wxSocketBase::RestoreState}{wxsocketbaserestorestate} | |
443 | ||
e79848ac GL |
444 | % --------------------------------------------------------------------------- |
445 | % Socket callbacks | |
446 | % --------------------------------------------------------------------------- | |
42ff6409 | 447 | \membersection{wxSocketBase::SetEventHandler}\label{wxsocketbaseseteventhandler} |
e79848ac | 448 | |
e79848ac GL |
449 | \func{void}{SetEventHandler}{\param{wxEvtHandler\&}{ evt\_hdlr}, \param{int}{ id = -1}} |
450 | ||
451 | Sets an event handler to be called when a socket event occured. | |
452 | ||
453 | \wxheading{Parameters} | |
454 | ||
455 | \docparam{evt\_hdlr}{Specifies the event handler you want to use.} | |
42ff6409 | 456 | |
e79848ac GL |
457 | \docparam{id}{The id of socket event.} |
458 | ||
459 | \wxheading{See also} | |
460 | ||
461 | \helpref{wxSocketEvent}{wxsocketevent} | |
462 | ||
463 | % --------------------------------------------------------------------------- | |
464 | % CLASS wxSocketClient | |
465 | % --------------------------------------------------------------------------- | |
e79848ac GL |
466 | \section{\class{wxSocketClient}}\label{wxsocketclient} |
467 | ||
468 | \wxheading{Derived from} | |
469 | ||
470 | \helpref{wxSocketBase}{wxsocketbase} | |
471 | ||
472 | % --------------------------------------------------------------------------- | |
473 | % Members | |
474 | % --------------------------------------------------------------------------- | |
e79848ac GL |
475 | % |
476 | % wxSocketClient | |
477 | % | |
e79848ac | 478 | \membersection{wxSocketClient::wxSocketClient} |
42ff6409 | 479 | |
e79848ac GL |
480 | \func{}{wxSocketClient}{\param{wxSockFlags}{ flags = wxSocketBase::NONE}} |
481 | ||
482 | Constructs a new wxSocketClient. | |
42ff6409 JS |
483 | |
484 | {\bf Warning !} The created socket client needs to be registered to a socket handler (See \helpref{wxSocketHandler}{wxsockethandler}). | |
e79848ac GL |
485 | |
486 | \wxheading{Parameters} | |
487 | ||
488 | \docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})} | |
489 | ||
490 | % | |
491 | % ~wxSocketClient | |
492 | % | |
e79848ac | 493 | \membersection{wxSocketClient::\destruct{wxSocketClient}} |
42ff6409 | 494 | |
e79848ac GL |
495 | \func{}{\destruct{wxSocketClient}}{\void} |
496 | ||
497 | Destructs a wxSocketClient object. | |
498 | ||
499 | % | |
500 | % Connect | |
501 | % | |
42ff6409 | 502 | \membersection{wxSocketClient::Connect}\label{wxsocketclientconnect} |
e79848ac | 503 | |
e79848ac GL |
504 | \func{bool}{Connect}{\param{wxSockAddress\&}{ address}, \param{bool}{ wait = TRUE}} |
505 | ||
506 | Connects to a server using the specified address. If {\it wait} is TRUE, Connect | |
507 | will wait for the socket ready to send or receive data. | |
508 | ||
509 | \wxheading{Parameters} | |
510 | ||
511 | \docparam{address}{Address of the server.} | |
42ff6409 | 512 | |
e79848ac GL |
513 | \docparam{wait}{If true, waits for the connection to be ready.} |
514 | ||
515 | \wxheading{Return value} | |
516 | ||
517 | Returns TRUE if the connection is established and no error occurs. | |
518 | ||
519 | \wxheading{See also} | |
520 | ||
521 | \helpref{wxSocketClient::WaitOnConnect}{wxsocketclientwaitonconnect} | |
522 | ||
523 | % | |
524 | % WaitOnConnect | |
525 | % | |
42ff6409 | 526 | \membersection{wxSocketClient::WaitOnConnect}\label{wxsocketclientwaitonconnect} |
e79848ac | 527 | |
e79848ac GL |
528 | \func{bool}{WaitOnConnect}{\param{long}{ seconds = -1}, \param{long}{ microseconds = 0}} |
529 | ||
530 | Wait for a "connect" event. | |
531 | ||
532 | \wxheading{See also} | |
533 | ||
534 | \helpref{wxSocketBase::Wait}{wxsocketbasewait} for a detailed description. | |
535 | ||
536 | % --------------------------------------------------------------------------- | |
42ff6409 | 537 | % CLASS: wxSocketEvent |
e79848ac | 538 | % --------------------------------------------------------------------------- |
42ff6409 | 539 | \section{\class{wxSocketEvent}}\label{wxsocketevent} |
e79848ac | 540 | |
42ff6409 | 541 | This event class contains information about socket events. |
e79848ac GL |
542 | |
543 | \wxheading{Derived from} | |
544 | ||
42ff6409 | 545 | \helpref{wxEvent}{wxevent} |
e79848ac | 546 | |
42ff6409 | 547 | \wxheading{Event table macros} |
e79848ac | 548 | |
42ff6409 JS |
549 | To process a socket event, use these event handler macros to direct input to member |
550 | functions that take a wxSocketEvent argument. | |
e79848ac | 551 | |
42ff6409 JS |
552 | \twocolwidtha{7cm} |
553 | \begin{twocollist}\itemsep=0pt | |
554 | \twocolitem{{\bf EVT\_SOCKET(id, func)}}{Process a socket event, supplying the member function.} | |
555 | \end{twocollist}% | |
e79848ac GL |
556 | |
557 | \wxheading{See also} | |
558 | ||
42ff6409 JS |
559 | \helpref{wxSocketHandler}{wxsockethandler},\rtfsp |
560 | \helpref{wxSocketBase}{wxsocketbase},\rtfsp | |
561 | \helpref{wxSocketClient}{wxsocketclient},\rtfsp | |
562 | \helpref{wxSocketServer}{wxsocketserver} | |
e79848ac | 563 | |
42ff6409 | 564 | \latexignore{\rtfignore{\wxheading{Members}}} |
e79848ac | 565 | |
42ff6409 | 566 | \membersection{wxSocketEvent::wxSocketEvent} |
e79848ac | 567 | |
42ff6409 | 568 | \func{}{wxSocketEvent}{\param{int}{ id = 0}} |
e79848ac | 569 | |
42ff6409 | 570 | Constructor. |
e79848ac | 571 | |
42ff6409 | 572 | \membersection{wxSocketEvent::SocketEvent}\label{wxsocketeventsocketevent} |
e79848ac | 573 | |
42ff6409 | 574 | \constfunc{wxSocketBase::wxRequestEvent}{SocketEvent}{\void} |
e79848ac | 575 | |
42ff6409 | 576 | Returns the socket event type. |
e79848ac GL |
577 | |
578 | % --------------------------------------------------------------------------- | |
579 | % CLASS: wxSocketHandler | |
580 | % --------------------------------------------------------------------------- | |
e79848ac GL |
581 | \section{\class{wxSocketHandler}}\label{wxsockethandler} |
582 | ||
583 | \wxheading{Derived from} | |
584 | ||
585 | \helpref{wxObject}{wxobject} | |
586 | ||
587 | % --------------------------------------------------------------------------- | |
588 | % Members | |
589 | % --------------------------------------------------------------------------- | |
e79848ac GL |
590 | \latexignore{\rtfignore{\wxheading{Members}}} |
591 | ||
592 | % | |
593 | % wxSocketHandler | |
594 | % | |
595 | \membersection{wxSocketHandler::wxSocketHandler} | |
42ff6409 | 596 | |
e79848ac GL |
597 | \func{}{wxSocketHandler}{\void} |
598 | ||
599 | Constructs a new wxSocketHandler. | |
42ff6409 JS |
600 | |
601 | It is advised to use \helpref{wxSocketHandler::Master}{wxsockethandlermaster} to | |
602 | get a socket handler. But creating a socket handler is useful to group | |
e79848ac GL |
603 | many sockets. |
604 | ||
605 | % | |
606 | % ~wxSocketHandler | |
607 | % | |
e79848ac | 608 | \membersection{wxSocketHandler::\destruct{wxSocketHandler}} |
42ff6409 | 609 | |
e79848ac GL |
610 | \func{}{\destruct{wxSocketHandler}}{\void} |
611 | ||
612 | Destructs a wxSocketHandler object. | |
613 | ||
614 | % | |
615 | % Register | |
616 | % | |
e79848ac | 617 | \membersection{wxSocketHandler::Register} |
42ff6409 | 618 | |
e79848ac GL |
619 | \func{void}{Register}{\param{wxSocketBase *}{socket}} |
620 | ||
621 | Register a socket: if it is already registered in this handler it will just | |
622 | return immediately. | |
623 | ||
624 | \wxheading{Parameters} | |
625 | ||
626 | \docparam{socket}{Socket to be registered.} | |
627 | ||
628 | % | |
629 | % UnRegister | |
630 | % | |
e79848ac | 631 | \membersection{wxSocketHandler::UnRegister} |
42ff6409 | 632 | |
e79848ac GL |
633 | \func{void}{UnRegister}{\param{wxSocketBase *}{socket}} |
634 | ||
635 | UnRegister a socket: if it isn't registered in this handler it will just | |
636 | return. | |
637 | ||
638 | \wxheading{Parameters} | |
639 | ||
640 | \docparam{socket}{Socket to be unregistered.} | |
641 | ||
642 | % | |
643 | % Count | |
644 | % | |
e79848ac | 645 | \membersection{wxSocketHandler::Count} |
42ff6409 | 646 | |
e79848ac GL |
647 | \constfunc{unsigned long}{Count}{\void} |
648 | ||
649 | Returns the number of sockets registered in the handler. | |
650 | ||
651 | \wxheading{Return value} | |
652 | ||
653 | Number of sockets registered. | |
654 | ||
655 | % | |
656 | % CreateServer | |
657 | % | |
e79848ac | 658 | \membersection{wxSocketHandler::CreateServer} |
42ff6409 | 659 | |
e79848ac GL |
660 | \func{wxSocketServer *}{CreateServer}{\param{wxSockAddress\&}{ address}, \param{wxSocketBase::wxSockFlags}{ flags = wxSocketbase::NONE}} |
661 | ||
662 | Creates a new wxSocketServer object. The object is automatically registered | |
663 | to the current socket handler. | |
664 | For a detailed description of the parameters, see \helpref{wxSocketServer::wxSocketServer}{wxsocketserverconstr}. | |
665 | ||
666 | \wxheading{Return value} | |
667 | ||
668 | Returns a new socket server. | |
669 | ||
670 | % | |
671 | % CreateClient | |
672 | % | |
e79848ac | 673 | \membersection{wxSocketHandler::CreateClient} |
42ff6409 | 674 | |
e79848ac GL |
675 | \func{wxSocketServer *}{CreateClient}{\param{wxSocketBase::wxSockFlags}{ flags = wxSocketbase::NONE}} |
676 | ||
677 | Creates a new wxSocketClient object. The object is automatically registered | |
678 | to the current socket handler. | |
42ff6409 | 679 | |
e79848ac GL |
680 | For a detailed description of the parameters, see \helpref{wxSocketClient::Connect}{wxsocketclientconnect}. |
681 | ||
682 | \wxheading{Return value} | |
683 | ||
684 | Returns a new socket client. | |
685 | ||
686 | % | |
687 | % Master | |
688 | % | |
42ff6409 | 689 | \membersection{wxSocketHandler::Master}\label{wxsockethandlermaster} |
e79848ac | 690 | |
e79848ac GL |
691 | \func{static wxSocketHandler\&}{Master}{\void} |
692 | ||
693 | Returns a default socket handler. | |
b80dc5fe GL |
694 | |
695 | % | |
696 | % Wait | |
697 | % | |
698 | \membersection{wxSocketHandler::Wait} | |
42ff6409 | 699 | |
b80dc5fe GL |
700 | \func{int}{Wait}{\param{long}{ seconds},\param{long}{ microseconds}} |
701 | ||
702 | Wait for an event on all registered sockets. | |
703 | ||
704 | \wxheading{Parameters} | |
705 | ||
706 | \docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.} | |
42ff6409 | 707 | |
b80dc5fe GL |
708 | \docparam{microsecond}{Number of microseconds to wait.} |
709 | ||
710 | \wxheading{Return value} | |
711 | ||
712 | Returns 0 if a timeout occured, else the number of events detected. | |
713 | ||
714 | \wxheading{See also} | |
715 | ||
42ff6409 | 716 | \helpref{wxSocketBase::Wait}{wxsocketbasewait} |
b80dc5fe GL |
717 | |
718 | % | |
719 | % YieldSock | |
720 | % | |
721 | \membersection{wxSocketHandler::YieldSock} | |
42ff6409 | 722 | |
b80dc5fe GL |
723 | \func{void}{YieldSock}{\void} |
724 | ||
725 | Execute pending requests in all registered sockets. | |
62448488 | 726 | |
42ff6409 JS |
727 | % --------------------------------------------------------------------------- |
728 | % CLASS: wxSocketServer | |
729 | % --------------------------------------------------------------------------- | |
730 | \section{\class{wxSocketServer}}\label{wxsocketserver} | |
731 | ||
732 | \wxheading{Derived from} | |
733 | ||
734 | \helpref{wxSocketBase}{wxsocketbase} | |
735 | ||
736 | % --------------------------------------------------------------------------- | |
737 | % Members | |
738 | % --------------------------------------------------------------------------- | |
739 | \latexignore{\rtfignore{\wxheading{Members}}} | |
740 | ||
741 | % | |
742 | % wxSocketServer | |
743 | % | |
744 | \membersection{wxSocketServer::wxSocketServer}\label{wxsocketserverconstr} | |
745 | ||
746 | \func{}{wxSocketServer}{\param{wxSockAddress\&}{ address}, \param{wxSockFlags}{ flags = wxSocketBase::NONE}} | |
747 | ||
748 | Constructs a new wxSocketServer. | |
749 | ||
750 | {\bf Warning !} The created object needs to be registered to a socket handler | |
751 | (see \helpref{wxSocketHandler}{wxsockethandler}). | |
752 | ||
753 | \wxheading{Parameters} | |
754 | ||
755 | \docparam{address}{Specifies the local address for the server (e.g. port number).} | |
756 | ||
757 | \docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})} | |
758 | ||
759 | % | |
760 | % ~wxSocketServer | |
761 | % | |
762 | \membersection{wxSocketServer::\destruct{wxSocketServer}} | |
763 | ||
764 | \func{}{\destruct{wxSocketServer}}{\void} | |
765 | ||
766 | Destructs a wxSocketServer object (it doesn't close the accepted connection). | |
767 | ||
768 | % | |
769 | % Accept | |
770 | % | |
771 | \membersection{wxSocketServer::Accept} | |
772 | ||
773 | \func{wxSocketBase *}{Accept}{\void} | |
774 | ||
775 | Creates a new object wxSocketBase and accepts an incoming connection. {\bf Warning !} This function will block the GUI. | |
776 | ||
777 | \wxheading{Return value} | |
778 | ||
779 | Returns an opened socket connection. | |
780 | ||
781 | \wxheading{See also} | |
782 | ||
783 | \helpref{wxSocketServer::AcceptWith}{wxsocketserveracceptwith} | |
784 | ||
785 | % | |
786 | % AcceptWith | |
787 | % | |
788 | \membersection{wxSocketServer::AcceptWith}\label{wxsocketserveracceptwith} | |
789 | ||
790 | \func{bool}{AcceptWith}{\param{wxSocketBase\&}{ socket}} | |
791 | ||
792 | Accept an incoming connection using the specified socket object. | |
793 | This is useful when someone wants to inherit wxSocketBase. | |
794 | ||
795 | \wxheading{Parameters} | |
796 | ||
797 | \docparam{socket}{Socket to be initialized} | |
798 | ||
799 | \wxheading{Return value} | |
800 | ||
801 | Returns TRUE if no error occurs, else FALSE. | |
802 | ||
803 |