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