]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | \twocolwidtha{7cm}% | |
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 | % --------------------------------------------------------------------------- | |
24 | \wxheading{See also} | |
25 | ||
26 | \helpref{wxSocketEvent}{wxsocketevent}\\ | |
27 | \helpref{wxSocketClient}{wxsocketclient}\\ | |
28 | \helpref{wxSocketServer}{wxsocketserver} | |
29 | ||
30 | % --------------------------------------------------------------------------- | |
31 | % Members | |
32 | % --------------------------------------------------------------------------- | |
33 | \latexignore{\rtfignore{\wxheading{Members}}} | |
34 | ||
35 | \membersection{wxSocketBase::wxSocketBase} | |
36 | ||
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 | ||
71 | \membersection{wxSocketBase::IsData}\label{wxsocketbaseisdata} | |
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 | % --------------------------------------------------------------------------- | |
104 | % | |
105 | % Peek | |
106 | % | |
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.} | |
117 | ||
118 | \docparam{nbytes}{Number of bytes.} | |
119 | ||
120 | \wxheading{Return value} | |
121 | ||
122 | Returns a reference to the current object. | |
123 | ||
124 | \wxheading{See also} | |
125 | ||
126 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ | |
127 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
128 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror} | |
129 | ||
130 | % | |
131 | % Read | |
132 | % | |
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.} | |
142 | ||
143 | \docparam{nbytes}{Number of bytes.} | |
144 | ||
145 | \wxheading{Return value} | |
146 | ||
147 | Returns a reference to the current object. | |
148 | ||
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 | ||
163 | \wxheading{See also} | |
164 | ||
165 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}, | |
166 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, | |
167 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror} | |
168 | ||
169 | \membersection{wxSocketBase::SetFlags}\label{wxsocketbasesetflags} | |
170 | ||
171 | \func{void}{SetFlags}{\param{wxSockFlags}{ flags}} | |
172 | ||
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} | |
180 | ||
181 | % | |
182 | % Read | |
183 | % | |
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 | ||
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 | ||
202 | \wxheading{Parameters} | |
203 | ||
204 | \docparam{buffer}{Buffer where to get the data to write.} | |
205 | ||
206 | \docparam{nbytes}{Number of bytes.} | |
207 | ||
208 | \wxheading{Return value} | |
209 | ||
210 | Returns a reference to the current object. | |
211 | ||
212 | \wxheading{See also} | |
213 | ||
214 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ | |
215 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
216 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror} | |
217 | ||
218 | % | |
219 | % WriteMsg | |
220 | % | |
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.} | |
232 | ||
233 | \docparam{nbytes}{Number of bytes.} | |
234 | ||
235 | \wxheading{Return value} | |
236 | ||
237 | Returns a reference to the current object. | |
238 | ||
239 | \wxheading{See also} | |
240 | ||
241 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ | |
242 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
243 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}\\ | |
244 | \helpref{wxSocketBase::ReadMsg}{wxsocketbasereadmsg} | |
245 | ||
246 | % | |
247 | % ReadMsg | |
248 | % | |
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.} | |
260 | ||
261 | \docparam{nbytes}{Number of bytes allocated for the buffer.} | |
262 | ||
263 | \wxheading{Return value} | |
264 | ||
265 | Returns a reference to the current object. | |
266 | ||
267 | \wxheading{See also} | |
268 | ||
269 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ | |
270 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
271 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}\\ | |
272 | \helpref{wxSocketBase::WriteMsg}{wxsocketbasewritemsg} | |
273 | ||
274 | % | |
275 | % Unread | |
276 | % | |
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.} | |
288 | ||
289 | \docparam{nbytes}{Number of bytes.} | |
290 | ||
291 | \wxheading{Return value} | |
292 | ||
293 | Returns a reference to the current object. | |
294 | ||
295 | \wxheading{See also} | |
296 | ||
297 | \helpref{wxSocketBase::Error}{wxsocketbaseerror}\\ | |
298 | \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}\\ | |
299 | \helpref{wxSocketBase::LastError}{wxsocketbaselasterror} | |
300 | ||
301 | % | |
302 | % Discard | |
303 | % | |
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} | |
315 | ||
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.} | |
325 | ||
326 | \docparam{microsecond}{Number of microseconds to wait.} | |
327 | ||
328 | \wxheading{Return value} | |
329 | ||
330 | Returns TRUE if an event occured, FALSE if the timeout was reached. | |
331 | ||
332 | \wxheading{See also} | |
333 | ||
334 | \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread}\\ | |
335 | \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}\\ | |
336 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} | |
337 | ||
338 | % | |
339 | % WaitForRead | |
340 | % | |
341 | \membersection{wxSocketBase::WaitForRead}\label{wxsocketbasewaitforread} | |
342 | ||
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.} | |
350 | ||
351 | \docparam{microsecond}{Number of microseconds to wait.} | |
352 | ||
353 | \wxheading{Return value} | |
354 | ||
355 | Returns TRUE if a byte arrived, FALSE if the timeout was reached. | |
356 | ||
357 | \wxheading{See also} | |
358 | ||
359 | \helpref{wxSocketBase::Wait}{wxsocketbasewait}\\ | |
360 | \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}\\ | |
361 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} | |
362 | ||
363 | % | |
364 | % WaitForWrite | |
365 | % | |
366 | \membersection{wxSocketBase::WaitForWrite}\label{wxsocketbasewaitforwrite} | |
367 | ||
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.} | |
375 | ||
376 | \docparam{microsecond}{Number of microseconds to wait.} | |
377 | ||
378 | \wxheading{Return value} | |
379 | ||
380 | Returns TRUE if a write event occured, FALSE if the timeout was reached. | |
381 | ||
382 | \wxheading{See also} | |
383 | ||
384 | \helpref{wxSocketBase::Wait}{wxsocketbasewait}\\ | |
385 | \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread}\\ | |
386 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} | |
387 | ||
388 | % | |
389 | % WaitForLost | |
390 | % | |
391 | \membersection{wxSocketBase::WaitForLost}\label{wxsocketbasewaitforlost} | |
392 | ||
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.} | |
401 | ||
402 | \docparam{microsecond}{Number of microseconds to wait.} | |
403 | ||
404 | \wxheading{Return value} | |
405 | ||
406 | Returns TRUE if a "lost" event occured, FALSE if the timeout was reached. | |
407 | ||
408 | \wxheading{See also} | |
409 | ||
410 | \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread}\\ | |
411 | \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}\\ | |
412 | \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost} | |
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} | |
426 | ||
427 | % --------------------------------------------------------------------------- | |
428 | % Socket state | |
429 | % --------------------------------------------------------------------------- | |
430 | % | |
431 | % SaveState | |
432 | % | |
433 | \membersection{wxSocketBase::SaveState}\label{wxsocketbasesavestate} | |
434 | ||
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 | ||
444 | % --------------------------------------------------------------------------- | |
445 | % Socket callbacks | |
446 | % --------------------------------------------------------------------------- | |
447 | \membersection{wxSocketBase::SetEventHandler}\label{wxsocketbaseseteventhandler} | |
448 | ||
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.} | |
456 | ||
457 | \docparam{id}{The id of socket event.} | |
458 | ||
459 | \wxheading{See also} | |
460 | ||
461 | \helpref{wxSocketEvent}{wxsocketevent} | |
462 | ||
463 | % --------------------------------------------------------------------------- | |
464 | % CLASS wxSocketClient | |
465 | % --------------------------------------------------------------------------- | |
466 | \section{\class{wxSocketClient}}\label{wxsocketclient} | |
467 | ||
468 | \wxheading{Derived from} | |
469 | ||
470 | \helpref{wxSocketBase}{wxsocketbase} | |
471 | ||
472 | % --------------------------------------------------------------------------- | |
473 | % Members | |
474 | % --------------------------------------------------------------------------- | |
475 | % | |
476 | % wxSocketClient | |
477 | % | |
478 | \membersection{wxSocketClient::wxSocketClient} | |
479 | ||
480 | \func{}{wxSocketClient}{\param{wxSockFlags}{ flags = wxSocketBase::NONE}} | |
481 | ||
482 | Constructs a new wxSocketClient. | |
483 | ||
484 | {\bf Warning !} The created socket client needs to be registered to a socket handler (See \helpref{wxSocketHandler}{wxsockethandler}). | |
485 | ||
486 | \wxheading{Parameters} | |
487 | ||
488 | \docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})} | |
489 | ||
490 | % | |
491 | % ~wxSocketClient | |
492 | % | |
493 | \membersection{wxSocketClient::\destruct{wxSocketClient}} | |
494 | ||
495 | \func{}{\destruct{wxSocketClient}}{\void} | |
496 | ||
497 | Destructs a wxSocketClient object. | |
498 | ||
499 | % | |
500 | % Connect | |
501 | % | |
502 | \membersection{wxSocketClient::Connect}\label{wxsocketclientconnect} | |
503 | ||
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.} | |
512 | ||
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 | % | |
526 | \membersection{wxSocketClient::WaitOnConnect}\label{wxsocketclientwaitonconnect} | |
527 | ||
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 | % --------------------------------------------------------------------------- | |
537 | % CLASS: wxSocketEvent | |
538 | % --------------------------------------------------------------------------- | |
539 | \section{\class{wxSocketEvent}}\label{wxsocketevent} | |
540 | ||
541 | This event class contains information about socket events. | |
542 | ||
543 | \wxheading{Derived from} | |
544 | ||
545 | \helpref{wxEvent}{wxevent} | |
546 | ||
547 | \wxheading{Event table macros} | |
548 | ||
549 | To process a socket event, use these event handler macros to direct input to member | |
550 | functions that take a wxSocketEvent argument. | |
551 | ||
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}% | |
556 | ||
557 | \wxheading{See also} | |
558 | ||
559 | \helpref{wxSocketHandler}{wxsockethandler},\rtfsp | |
560 | \helpref{wxSocketBase}{wxsocketbase},\rtfsp | |
561 | \helpref{wxSocketClient}{wxsocketclient},\rtfsp | |
562 | \helpref{wxSocketServer}{wxsocketserver} | |
563 | ||
564 | \latexignore{\rtfignore{\wxheading{Members}}} | |
565 | ||
566 | \membersection{wxSocketEvent::wxSocketEvent} | |
567 | ||
568 | \func{}{wxSocketEvent}{\param{int}{ id = 0}} | |
569 | ||
570 | Constructor. | |
571 | ||
572 | \membersection{wxSocketEvent::SocketEvent}\label{wxsocketeventsocketevent} | |
573 | ||
574 | \constfunc{wxSocketBase::wxRequestEvent}{SocketEvent}{\void} | |
575 | ||
576 | Returns the socket event type. | |
577 | ||
578 | % --------------------------------------------------------------------------- | |
579 | % CLASS: wxSocketHandler | |
580 | % --------------------------------------------------------------------------- | |
581 | \section{\class{wxSocketHandler}}\label{wxsockethandler} | |
582 | ||
583 | \wxheading{Derived from} | |
584 | ||
585 | \helpref{wxObject}{wxobject} | |
586 | ||
587 | % --------------------------------------------------------------------------- | |
588 | % Members | |
589 | % --------------------------------------------------------------------------- | |
590 | \latexignore{\rtfignore{\wxheading{Members}}} | |
591 | ||
592 | % | |
593 | % wxSocketHandler | |
594 | % | |
595 | \membersection{wxSocketHandler::wxSocketHandler} | |
596 | ||
597 | \func{}{wxSocketHandler}{\void} | |
598 | ||
599 | Constructs a new wxSocketHandler. | |
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 | |
603 | many sockets. | |
604 | ||
605 | % | |
606 | % ~wxSocketHandler | |
607 | % | |
608 | \membersection{wxSocketHandler::\destruct{wxSocketHandler}} | |
609 | ||
610 | \func{}{\destruct{wxSocketHandler}}{\void} | |
611 | ||
612 | Destructs a wxSocketHandler object. | |
613 | ||
614 | % | |
615 | % Register | |
616 | % | |
617 | \membersection{wxSocketHandler::Register} | |
618 | ||
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 | % | |
631 | \membersection{wxSocketHandler::UnRegister} | |
632 | ||
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 | % | |
645 | \membersection{wxSocketHandler::Count} | |
646 | ||
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 | % | |
658 | \membersection{wxSocketHandler::CreateServer} | |
659 | ||
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 | % | |
673 | \membersection{wxSocketHandler::CreateClient} | |
674 | ||
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. | |
679 | ||
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 | % | |
689 | \membersection{wxSocketHandler::Master}\label{wxsockethandlermaster} | |
690 | ||
691 | \func{static wxSocketHandler\&}{Master}{\void} | |
692 | ||
693 | Returns a default socket handler. | |
694 | ||
695 | % | |
696 | % Wait | |
697 | % | |
698 | \membersection{wxSocketHandler::Wait} | |
699 | ||
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.} | |
707 | ||
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 | ||
716 | \helpref{wxSocketBase::Wait}{wxsocketbasewait} | |
717 | ||
718 | % | |
719 | % YieldSock | |
720 | % | |
721 | \membersection{wxSocketHandler::YieldSock} | |
722 | ||
723 | \func{void}{YieldSock}{\void} | |
724 | ||
725 | Execute pending requests in all registered sockets. | |
726 | ||
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 |