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