]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/socket.tex
f802da83532b5c94bb4460dfc50efba48611fba4
[wxWidgets.git] / docs / latex / wx / socket.tex
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% Name: socket.tex
3 %% Purpose: wxSocket docs
4 %% Author: Guillermo Rodriguez Garcia <guille@iies.es>
5 %% Modified by:
6 %% Created: 1999
7 %% RCS-ID: $Id$
8 %% Copyright: (c) wxWindows team
9 %% Licence: wxWindows licence
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12 \section{\class{wxSocketBase}}\label{wxsocketbase}
13
14 wxSocketBase is the base class for all socket-related objects, and it
15 defines all basic IO functionality.
16
17 \wxheading{Derived from}
18
19 \helpref{wxEvtHandler}{wxevthandler}
20
21 \wxheading{Include files}
22
23 <wx/socket.h>
24
25 \wxheading{wxSocket errors}
26
27 \twocolwidtha{7cm}
28 \begin{twocollist}\itemsep=0pt
29 \twocolitem{{\bf wxSOCKET\_NOERROR}}{No error happened.}
30 \twocolitem{{\bf wxSOCKET\_INVOP}}{Invalid operation.}
31 \twocolitem{{\bf wxSOCKET\_IOERR}}{Input/Output error.}
32 \twocolitem{{\bf wxSOCKET\_INVADDR}}{Invalid address passed to wxSocket.}
33 \twocolitem{{\bf wxSOCKET\_INVSOCK}}{Invalid socket (uninitialized).}
34 \twocolitem{{\bf wxSOCKET\_NOHOST}}{No corresponding host.}
35 \twocolitem{{\bf wxSOCKET\_INVPORT}}{Invalid port.}
36 \twocolitem{{\bf wxSOCKET\_WOULDBLOCK}}{The socket is non-blocking and the operation would block.}
37 \twocolitem{{\bf wxSOCKET\_TIMEDOUT}}{The timeout for this operation expired.}
38 \twocolitem{{\bf wxSOCKET\_MEMERR}}{Memory exhausted.}
39 \end{twocollist}
40
41 \wxheading{wxSocket events}
42
43 \twocolwidtha{7cm}
44 \begin{twocollist}\itemsep=0pt
45 \twocolitem{{\bf wxSOCKET\_INPUT}}{There is data available for reading.}
46 \twocolitem{{\bf wxSOCKET\_OUTPUT}}{The socket is ready to be written to.}
47 \twocolitem{{\bf wxSOCKET\_CONNECTION}}{Incoming connection (server), or connection establishment (client).}
48 \twocolitem{{\bf wxSOCKET\_LOST}}{The connection has been closed.}
49 \end{twocollist}
50
51 A brief note on how to use these events:
52
53 The {\bf wxSOCKET\_INPUT} event will be issued whenever there is data
54 available for reading. This will be the case if the input queue was
55 empty and new data arrives, or if the application has read some data
56 yet there is still more data available. This means that the application
57 does not need to read all available data in response to a
58 {\bf wxSOCKET\_INPUT} event, as more events will be produced as
59 necessary.
60
61 The {\bf wxSOCKET\_OUTPUT} event is issued when a socket is first
62 connected with \helpref{Connect}{wxsocketclientconnect} or accepted
63 with \helpref{Accept}{wxsocketserveraccept}. After that, new
64 events will be generated only after an output operation fails
65 with {\bf wxSOCKET\_WOULDBLOCK} and buffer space becomes available
66 again. This means that the application should assume that it
67 can write data to the socket until an {\bf wxSOCKET\_WOULDBLOCK}
68 error occurs; after this, whenever the socket becomes writable
69 again the application will be notified with another
70 {\bf wxSOCKET\_OUTPUT} event.
71
72 The {\bf wxSOCKET\_CONNECTION} event is issued when a delayed connection
73 request completes succesfully (client) or when a new connection arrives
74 at the incoming queue (server).
75
76 The {\bf wxSOCKET\_LOST} event is issued when a close indication is
77 received for the socket. This means that the connection broke down or
78 that it was closed by the peer. Also, this event will be issued if
79 a delayed connection request fails.
80
81 \wxheading{Event handling}
82
83 To process events coming from a socket object, use the following event
84 handler macro to direct events to member functions that take a
85 \helpref{wxSocketEvent}{wxsocketevent} argument.
86
87 \twocolwidtha{7cm}%
88 \begin{twocollist}\itemsep=0pt
89 \twocolitem{{\bf EVT\_SOCKET(id, func)}}{Process a wxEVT\_SOCKET event.}
90 \end{twocollist}
91
92 \wxheading{See also}
93
94 \helpref{wxSocketEvent}{wxsocketevent},
95 \helpref{wxSocketClient}{wxsocketclient},
96 \helpref{wxSocketServer}{wxsocketserver},
97 \helpref{Sockets sample}{samplesockets}
98
99 % ---------------------------------------------------------------------------
100 % Function groups
101 % ---------------------------------------------------------------------------
102
103 \latexignore{\rtfignore{\wxheading{Function groups}}}
104
105 \membersection{Construction and destruction}
106
107 \helpref{wxSocketBase}{wxsocketbaseconstruct}\\
108 \helpref{\destruct{wxSocketBase}}{wxsocketbasedestruct}\\
109 \helpref{wxDestroy}{wxsocketbasedestroy}
110
111 \membersection{Socket state}
112
113 Functions to retrieve current state and miscellaneous info.
114
115 \helpref{Error}{wxsocketbaseerror}\\
116 \helpref{GetLocal}{wxsocketbasegetlocal}\\
117 \helpref{GetPeer}{wxsocketbasegetpeer}
118 \helpref{IsConnected}{wxsocketbaseisconnected}\\
119 \helpref{IsData}{wxsocketbaseisdata}\\
120 \helpref{IsDisconnected}{wxsocketbaseisdisconnected}\\
121 \helpref{LastCount}{wxsocketbaselastcount}\\
122 \helpref{LastError}{wxsocketbaselasterror}\\
123 \helpref{Ok}{wxsocketbaseok}\\
124 \helpref{SaveState}{wxsocketbasesavestate}\\
125 \helpref{RestoreState}{wxsocketbaserestorestate}
126
127 \membersection{Basic IO}
128
129 Functions that perform basic IO functionality.
130
131 \helpref{Close}{wxsocketbaseclose}\\
132 \helpref{Discard}{wxsocketbasediscard}\\
133 \helpref{Peek}{wxsocketbasepeek}\\
134 \helpref{Read}{wxsocketbaseread}\\
135 \helpref{ReadMsg}{wxsocketbasereadmsg}\\
136 \helpref{Unread}{wxsocketbaseunread}\\
137 \helpref{Write}{wxsocketbasewrite}\\
138 \helpref{WriteMsg}{wxsocketbasewritemsg}
139
140 Functions that perform a timed wait on a certain IO condition.
141
142 \helpref{Wait}{wxsocketbasewait}\\
143 \helpref{WaitForRead}{wxsocketbasewaitforread}\\
144 \helpref{WaitForWrite}{wxsocketbasewaitforwrite}\\
145 \helpref{WaitForLost}{wxsocketbasewaitforlost}
146
147 Functions that allow applications to customize socket IO as needed.
148
149 \helpref{SetFlags}{wxsocketbasesetflags}\\
150 \helpref{SetTimeout}{wxsocketbasesettimeout}
151
152 \membersection{Handling socket events}
153
154 Functions that allow applications to receive socket events.
155
156 \helpref{Notify}{wxsocketbasenotify}\\
157 \helpref{SetNotify}{wxsocketbasesetnotify}\\
158 \helpref{SetEventHandler}{wxsocketbaseseteventhandler}
159
160 Callback functions are also available, but they are provided for backwards
161 compatibility only. Their use is discouraged in favour of events, and should
162 be considered deprecated.
163
164 \helpref{Callback}{wxsocketbasecallback}\\
165 \helpref{CallbackData}{wxsocketbasecallbackdata}
166
167
168 % ---------------------------------------------------------------------------
169 % Members here
170 % ---------------------------------------------------------------------------
171
172 \helponly{\insertatlevel{2}{
173
174 \wxheading{Members}
175
176 }}
177
178 \membersection{wxSocketBase::wxSocketBase}\label{wxsocketbaseconstruct}
179
180 \func{}{wxSocketBase}{\void}
181
182 Default constructor. Don't use it directly; instead, use
183 \helpref{wxSocketClient}{wxsocketclient} to construct a socket client, or
184 \helpref{wxSocketServer}{wxsocketserver} to construct a socket server.
185
186 \membersection{wxSocketBase::\destruct{wxSocketBase}}\label{wxsocketbasedestruct}
187
188 \func{}{\destruct{wxSocketBase}}{\void}
189
190 Destructor. Do not destroy a socket using the delete operator directly;
191 use \helpref{wxsocketbasedestroy} instead. Also, do not create socket
192 objects in the stack.
193
194 %
195 % Callback
196 %
197 \membersection{wxSocketBase::Callback}\label{wxsocketbasecallback}
198
199 \func{wxSocketBase::wxSockCbk}{Callback}{\param{wxSocketBase::wxSockCbk}{ callback}}
200
201 You can setup a callback function to be called when an event occurs.
202 The function will be called only for those events for which notification
203 has been enabled with \helpref{Notify}{wxsocketbasenotify} and
204 \helpref{SetNotify}{wxsocketbasesetnotify}. The prototype of the
205 callback must be as follows:
206
207 \begin{verbatim}
208 void SocketCallback(wxSocketBase& sock, wxSocketNotify evt, char *cdata);
209 \end{verbatim}
210
211 The first parameter is a reference to the socket object in which the
212 event occured. The second parameter tells you which event occured.
213 (See \helpref{wxSocket events}{wxsocketbase}). The third parameter
214 is the user data you specified using
215 \helpref{CallbackData}{wxsocketbasecallbackdata}.
216
217 Note that events are preferred over callbacks where possible.
218
219 \wxheading{Return value}
220
221 A pointer to the previous callback.
222
223 \wxheading{See also}
224
225 \helpref{wxSocketBase::CallbackData}{wxsocketbasecallbackdata},
226 \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify},
227 \helpref{wxSocketBase::Notify}{wxsocketbasenotify}
228
229 %
230 % CallbackData
231 %
232 \membersection{wxSocketBase::CallbackData}\label{wxsocketbasecallbackdata}
233
234 \func{char *}{CallbackData}{\param{char *}{cdata}}
235
236 This function sets the the user data which will be passed to a
237 callback function set via \helpref{Callback}{wxsocketbasecallback}.
238
239 Note that events are preferred over callbacks where possible.
240
241 \wxheading{Return value}
242
243 A pointer to the previous user data.
244
245 \helpref{wxSocketBase::Callback}{wxsocketbasecallback},
246 \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify},
247 \helpref{wxSocketBase::Notify}{wxsocketbasenotify}
248
249 %
250 % Close
251 %
252 \membersection{wxSocketBase::Close}\label{wxsocketbaseclose}
253
254 \func{void}{Close}{\void}
255
256 This function shuts down the socket, disabling further transmission and
257 reception of data; it also disables events for the socket and frees the
258 associated system resources. If you \helpref{Destroy}{wxsocketbasedestroy}
259 a socket, Close is automatically called.
260
261 \wxheading{Remark/Warning}
262
263 Although Close immediately disables events for the socket, it is possible
264 that event messages may be waiting in the application's event queue. The
265 application must therefore be prepared to handle socket event messages
266 even after calling Close.
267
268 %
269 % Destroy
270 %
271 \membersection{wxSocketBase::Destroy}\label{wxsocketbasedestroy}
272
273 \func{bool}{Destroy}{\void}
274
275 Destroys the socket safely. Use this function instead of the delete operator,
276 since otherwise socket events could reach the application even after the
277 socket has been destroyed. To prevent this problem, this function appends
278 the wxSocket to a list of object to be deleted on idle time, after all
279 events have been processed. For the same reason, you should avoid creating
280 socket objects in the stack.
281
282 Destroy calls \helpref{Close}{wxsocketbaseclose} automatically.
283
284 \wxheading{Return value}
285
286 Always TRUE.
287
288 %
289 % Discard
290 %
291 \membersection{wxSocketBase::Discard}\label{wxsocketbasediscard}
292
293 \func{wxSocketBase\&}{Discard}{\void}
294
295 This function simply deletes all bytes in the incoming queue. This function
296 always returns immediately and its operation is not affected by IO flags.
297
298 Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually discarded.
299
300 If you use \helpref{Error}{wxsocketbaseerror}, it will always return FALSE.
301
302 %
303 % Error
304 %
305 \membersection{wxSocketBase::Error}\label{wxsocketbaseerror}
306
307 \constfunc{bool}{Error}{\void}
308
309 Returns TRUE if an error occured in the last IO operation.
310
311 Use this function to check for an error condition after one of the
312 following calls: Discard, Peek, Read, ReadMsg, Unread, Write, WriteMsg.
313
314 %
315 % GetLocal
316 %
317 \membersection{wxSocketBase::GetLocal}\label{wxsocketbasegetlocal}
318
319 \constfunc{bool}{GetLocal}{\param{wxSockAddress\& }{addr\_man}}
320
321 This function returns the local address field of the socket. The local
322 address field contains the complete local address of the socket (local
323 address, local port, ...).
324
325 \wxheading{Return value}
326
327 It returns TRUE if no errors happened, FALSE otherwise.
328
329 %
330 % GetPeer
331 %
332 \membersection{wxSocketBase::GetPeer}\label{wxsocketbasegetpeer}
333
334 \constfunc{bool}{GetPeer}{\param{wxSockAddress\& }{addr\_man}}
335
336 This function returns the peer address field of the socket. The peer
337 address field contains the complete peer host address of the socket
338 (address, port, ...).
339
340 \wxheading{Return value}
341
342 It returns TRUE if no errors happened, FALSE otherwise.
343
344 %
345 % IsConnected
346 %
347 \membersection{wxSocketBase::IsConnected}\label{wxsocketbaseisconnected}
348
349 \constfunc{bool}{IsConnected}{\void}
350
351 Returns TRUE if the socket is connected.
352
353 %
354 % IsData
355 %
356 \membersection{wxSocketBase::IsData}\label{wxsocketbaseisdata}
357
358 \constfunc{bool}{IsData}{\void}
359
360 This function waits until the socket is readable. This might mean that
361 queued data is available for reading or, for streamed sockets, that
362 the connection has been closed, so that a read operation will complete
363 immediately without blocking (unless the {\bf wxSOCKET\_WAITALL} flag
364 is set, in which case the operation might still block).
365
366 \membersection{wxSocketBase::IsDisconnected}\label{wxsocketbaseisdisconnected}
367
368 %
369 % IsDisconnected
370 %
371 \constfunc{bool}{IsDisconnected}{\void}
372
373 Returns TRUE if the socket is not connected.
374
375 \membersection{wxSocketBase::LastCount}\label{wxsocketbaselastcount}
376
377 %
378 % LastCount
379 %
380 \constfunc{wxUint32}{LastCount}{\void}
381
382 Returns the number of bytes read or written by the last IO call.
383
384 Use this function to get the number of bytes actually transferred
385 after using one of the following IO calls: Discard, Peek, Read,
386 ReadMsg, Unread, Write, WriteMsg.
387
388 %
389 % LastError
390 %
391 \membersection{wxSocketBase::LastError}\label{wxsocketbaselasterror}
392
393 \constfunc{wxSocketError}{LastError}{\void}
394
395 Returns the last wxSocket error. See \helpref{wxSocket errors}{wxsocketbase}.
396
397 Please note that this function merely returns the last error code,
398 but it should not be used to determine if an error has occured (this
399 is because successful operations do not change the LastError value).
400 Use \helpref{Error}{wxsocketbaseerror} first, in order to determine
401 if the last IO call failed. If this returns TRUE, use LastError
402 to discover the cause of the error.
403
404 %
405 % Notify
406 %
407 \membersection{wxSocketBase::Notify}\label{wxsocketbasenotify}
408
409 \func{void}{Notify}{\param{bool}{ notify}}
410
411 According to the {\it notify} value, this function enables
412 or disables socket events. If {\it notify} is TRUE, the events
413 configured with \helpref{SetNotify}{wxsocketbasesetnotify} will
414 be sent to the application. If {\it notify} is FALSE; no events
415 will be sent.
416
417 %
418 % Ok
419 %
420 \membersection{wxSocketBase::Ok}\label{wxsocketbaseok}
421
422 \constfunc{bool}{Ok}{\void}
423
424 Returns TRUE if the socket is initialized and ready and FALSE in other
425 cases.
426
427 \wxheading{Remark/Warning}
428
429 For \helpref{wxSocketClient}{wxsocketclient}, Ok won't return TRUE unless
430 the client is connected to a server.
431
432 For \helpref{wxSocketServer}{wxsocketserver}, Ok will return TRUE if the
433 server could bind to the specified address and is already listening for
434 new connections.
435
436 Ok does not check for IO errors; use \helpref{Error}{wxsocketbaseerror}
437 instead for that purpose.
438
439 %
440 % RestoreState
441 %
442 \membersection{wxSocketBase::RestoreState}\label{wxsocketbaserestorestate}
443
444 \func{void}{RestoreState}{\void}
445
446 This function restores the previous state of the socket, as saved
447 with \helpref{SaveState}{wxsocketbasesavestate}
448
449 Calls to SaveState and RestoreState can be nested.
450
451 \wxheading{See also}
452
453 \helpref{wxSocketBase::SaveState}{wxsocketbasesavestate}
454
455 %
456 % SaveState
457 %
458 \membersection{wxSocketBase::SaveState}\label{wxsocketbasesavestate}
459
460 \func{void}{SaveState}{\void}
461
462 This function saves the current state of the socket in a stack. Socket
463 state includes flags, as set with \helpref{SetFlags}{wxsocketbasesetflags},
464 event mask, as set with \helpref{SetNotify}{wxsocketbasesetnotify} and
465 \helpref{Notify}{wxsocketbasenotify}, and current settings for the
466 asynchronous callbacks, as set with \helpref{Callback}{wxsocketbasecallback}
467 and \helpref{CallbackData}{wxsocketbasecallbackdata}.
468
469 Calls to SaveState and RestoreState can be nested.
470
471 \wxheading{See also}
472
473 \helpref{wxSocketBase::RestoreState}{wxsocketbaserestorestate}
474
475 %
476 % SetEventHandler
477 %
478 \membersection{wxSocketBase::SetEventHandler}\label{wxsocketbaseseteventhandler}
479
480 \func{void}{SetEventHandler}{\param{wxEvtHandler\&}{ evt\_hdlr}, \param{int}{ id = -1}}
481
482 Sets an event handler to be called when a socket event occurs. The
483 handler will be called for those events for which notification is
484 enabled with \helpref{SetNotify}{wxsocketbasesetnotify} and
485 \helpref{Notify}{wxsocketbasenotify}.
486
487 You can also specify a callback function to be called when an event
488 occurs, although if possible, events should be used instead of callbacks.
489 See \helpref{Callback}{wxsocketbasecallback} and
490 \helpref{CallbackData}{wxsocketbasecallbackdata}.
491
492 \wxheading{Parameters}
493
494 \docparam{evt\_hdlr}{Specifies the event handler you want to use.}
495
496 \docparam{id}{The id of socket event.}
497
498 \wxheading{See also}
499
500 \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify},
501 \helpref{wxSocketBase::Notify}{wxsocketbasenotify},
502 \helpref{wxSocketEvent}{wxsocketevent},
503 \helpref{wxEvtHandler}{wxevthandler},
504 \helpref{wxSocketBase::Callback}{wxsocketbasecallback},
505 \helpref{wxSocketBase::CallbackData}{wxsocketbasecallbackdata}
506
507 %
508 % SetFlags
509 %
510 \membersection{wxSocketBase::SetFlags}\label{wxsocketbasesetflags}
511
512 \func{void}{SetFlags}{\param{wxSocketBase::wxSockFlags}{ flags}}
513
514 \twocolwidtha{7cm}
515 \begin{twocollist}\itemsep=0pt
516 \twocolitem{{\bf wxSOCKET\_NONE}}{Normal functionality.}
517 \twocolitem{{\bf wxSOCKET\_NOWAIT}}{Read/write as much data as possible and return immediately.}
518 \twocolitem{{\bf wxSOCKET\_WAITALL}}{Wait for all required data to be read/written unless an error occurs.}
519 \twocolitem{{\bf wxSOCKET\_BLOCK}}{Block the GUI (do not yield) while reading/writing data.}
520 \end{twocollist}
521
522 A brief overview on how to use these flags follows.
523
524 If no flag is specified (this is the same as {\bf wxSOCKET\_NONE}),
525 IO calls will return after some data has been read or written, even
526 when the transfer might not be complete. This is the same as issuing
527 exactly one blocking low-level call to recv() or send(). Note that
528 {\it blocking} here refers to when the function returns, not to whether
529 the GUI blocks during this time.
530
531 If {\bf wxSOCKET\_NOWAIT} is specified, IO calls will return immediately.
532 Read operations will retrieve only available data. Write operations will
533 write as much data as possible, depending on how much space is available
534 in the output buffer. This is the same as issuing exactly one nonblocking
535 low-level call to recv() or send(). Note that {\it nonblocking} here
536 refers to when the function returns, not to whether the GUI blocks during
537 this time.
538
539 If {\bf wxSOCKET\_WAITALL} is specified, IO calls won't return until ALL
540 the data has been read or written (or until an error occurs), blocking if
541 necessary, and issuing several low level calls if necessary. This is the
542 same as having a loop which makes as many blocking low-level calls to
543 recv() or send() as needed so as to transfer all the data. Note that
544 {\it blocking} here refers to when the function returns, not to whether
545 the GUI blocks during this time.
546
547 The {\bf wxSOCKET\_BLOCK} flag controls whether the GUI blocks during
548 IO operations. If this flag is specified, the socket will not yield
549 during IO calls, so the GUI will remain blocked until the operation
550 completes. If it is not used, then the application must take extra
551 care to avoid unwanted reentrance.
552
553 So:
554
555 {\bf wxSOCKET\_NONE} will try to read at least SOME data, no matter how much.
556
557 {\bf wxSOCKET\_NOWAIT} will always return immediately, even if it cannot
558 read or write ANY data.
559
560 {\bf wxSOCKET\_WAITALL} will only return when it has read or written ALL
561 the data.
562
563 {\bf wxSOCKET\_BLOCK} has nothing to do with the previous flags and
564 it controls whether the GUI blocks.
565
566 %
567 % SetNotify
568 %
569 \membersection{wxSocketBase::SetNotify}\label{wxsocketbasesetnotify}
570
571 \func{void}{SetNotify}{\param{wxSocketEventFlags}{ flags}}
572
573 SetNotify specifies which socket events are to be sent to the event handler.
574 The {\it flags} parameter is a combination of flags ORed toghether. The
575 following flags can be used:
576
577 \twocolwidtha{7cm}
578 \begin{twocollist}\itemsep=0pt
579 \twocolitem{{\bf wxSOCKET\_INPUT\_FLAG}}{to receive wxSOCKET\_INPUT}
580 \twocolitem{{\bf wxSOCKET\_OUTPUT\_FLAG}}{to receive wxSOCKET\_OUTPUT}
581 \twocolitem{{\bf wxSOCKET\_CONNECTION\_FLAG}}{to receive wxSOCKET\_CONNECTION}
582 \twocolitem{{\bf wxSOCKET\_LOST\_FLAG}}{to receive wxSOCKET\_LOST}
583 \end{twocollist}
584
585 For example:
586
587 \begin{verbatim}
588 sock.SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
589 sock.Notify(TRUE);
590 \end{verbatim}
591
592 In this example, the user will be notified about incoming socket data and
593 whenever the connection is closed.
594
595 For more information on socket events see \helpref{wxSocket events}{wxsocketbase}.
596
597 %
598 % SetTimeout
599 %
600 \membersection{wxSocketBase::SetTimeout}\label{wxsocketbasesettimeout}
601
602 \func{void}{SetTimeout}{\param{int }{seconds}}
603
604 This function sets the default socket timeout in seconds. This timeout
605 applies to all IO calls, and also to the \helpref{Wait}{wxsocketbasewait}
606 family of functions if you don't specify a wait interval. Initially, the
607 default is set to 10 minutes.
608
609 %
610 % Peek
611 %
612 \membersection{wxSocketBase::Peek}\label{wxsocketbasepeek}
613
614 \func{wxSocketBase\&}{Peek}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}}
615
616 This function peeks a buffer of {\it nbytes} bytes from the socket.
617 Peeking a buffer doesn't delete it from the socket input queue.
618
619 Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually peeked.
620
621 Use \helpref{Error}{wxsocketbaseerror} to determine if the operation succeeded.
622
623 \wxheading{Parameters}
624
625 \docparam{buffer}{Buffer where to put peeked data.}
626
627 \docparam{nbytes}{Number of bytes.}
628
629 \wxheading{Return value}
630
631 Returns a reference to the current object.
632
633 \wxheading{Remark/Warning}
634
635 The exact behaviour of wxSocketBase::Peek depends on the combination
636 of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}
637
638 \wxheading{See also}
639
640 \helpref{wxSocketBase::Error}{wxsocketbaseerror},
641 \helpref{wxSocketBase::LastError}{wxsocketbaselasterror},
642 \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount},
643 \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}
644
645 %
646 % Read
647 %
648 \membersection{wxSocketBase::Read}\label{wxsocketbaseread}
649
650 \func{wxSocketBase\&}{Read}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}}
651
652 This function reads a buffer of {\it nbytes} bytes from the socket.
653
654 Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually read.
655
656 Use \helpref{Error}{wxsocketbaseerror} to determine if the operation succeeded.
657
658 \wxheading{Parameters}
659
660 \docparam{buffer}{Buffer where to put read data.}
661
662 \docparam{nbytes}{Number of bytes.}
663
664 \wxheading{Return value}
665
666 Returns a reference to the current object.
667
668 \wxheading{Remark/Warning}
669
670 The exact behaviour of wxSocketBase::Read depends on the combination
671 of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
672
673 \wxheading{See also}
674
675 \helpref{wxSocketBase::Error}{wxsocketbaseerror},
676 \helpref{wxSocketBase::LastError}{wxsocketbaselasterror},
677 \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount},
678 \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}
679
680 %
681 % ReadMsg
682 %
683 \membersection{wxSocketBase::ReadMsg}\label{wxsocketbasereadmsg}
684
685 \func{wxSocketBase\&}{ReadMsg}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}}
686
687 This function reads a buffer sent by \helpref{WriteMsg}{wxsocketbasewritemsg}
688 on a socket. If the buffer passed to the function isn't big enough, the
689 remaining bytes will be discarded. This function always waits for the
690 buffer to be entirely filled, unless an error occurs.
691
692 Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually read.
693
694 Use \helpref{Error}{wxsocketbaseerror} to determine if the operation succeeded.
695
696 \wxheading{Parameters}
697
698 \docparam{buffer}{Buffer where to put read data.}
699
700 \docparam{nbytes}{Size of the buffer.}
701
702 \wxheading{Return value}
703
704 Returns a reference to the current object.
705
706 \wxheading{Remark/Warning}
707
708 wxSocketBase::ReadMsg will behave as if the {\bf wxSOCKET\_WAITALL} flag
709 was always set and it will always ignore the {\bf wxSOCKET\_NOWAIT} flag.
710 The exact behaviour of ReadMsg depends on the {\bf wxSOCKET\_BLOCK} flag.
711 For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
712
713 \wxheading{See also}
714
715 \helpref{wxSocketBase::Error}{wxsocketbaseerror},
716 \helpref{wxSocketBase::LastError}{wxsocketbaselasterror},
717 \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount},
718 \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags},
719 \helpref{wxSocketBase::WriteMsg}{wxsocketbasewritemsg}
720
721 %
722 % Unread
723 %
724 \membersection{wxSocketBase::Unread}\label{wxsocketbaseunread}
725
726 \func{wxSocketBase\&}{Unread}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}}
727
728 This function unreads a buffer. That is, the data in the buffer is put back
729 in the incoming queue. This function is not affected by wxSocket flags.
730
731 If you use \helpref{LastCount}{wxsocketbaselastcount}, it will always return {\it nbytes}.
732
733 If you use \helpref{Error}{wxsocketbaseerror}, it will always return FALSE.
734
735 \wxheading{Parameters}
736
737 \docparam{buffer}{Buffer to be unread.}
738
739 \docparam{nbytes}{Number of bytes.}
740
741 \wxheading{Return value}
742
743 Returns a reference to the current object.
744
745 \wxheading{See also}
746
747 \helpref{wxSocketBase::Error}{wxsocketbaseerror},
748 \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount},
749 \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}
750
751 %
752 % Wait
753 %
754 \membersection{wxSocketBase::Wait}\label{wxsocketbasewait}
755
756 \func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
757
758 This function waits until one of the following conditions is TRUE. Note
759 that it is recommended to use the individual Wait functions to wait for
760 the required condition, instead of this one.
761
762 \begin{itemize}
763 \item The socket becomes readable.
764 \item The socket becomes writable.
765 \item An ongoing connection request has completed (only for clients)
766 \item An incoming connection request has arrived (only for servers)
767 \item The connection has been closed.
768 \end{itemize}
769
770 \wxheading{Parameters}
771
772 \docparam{seconds}{Number of seconds to wait.
773 If -1, it will wait for the default timeout,
774 as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
775
776 \docparam{millisecond}{Number of milliseconds to wait.}
777
778 \wxheading{Return value}
779
780 Returns TRUE when any of the above conditions is satisfied,
781 FALSE if the timeout was reached.
782
783 \wxheading{See also}
784
785 \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread},
786 \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite},
787 \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost}
788
789 %
790 % WaitForRead
791 %
792 \membersection{wxSocketBase::WaitForRead}\label{wxsocketbasewaitforread}
793
794 \func{bool}{WaitForRead}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
795
796 This function waits until the socket is readable. This might mean that
797 queued data is available for reading or, for streamed sockets, that
798 the connection has been closed, so that a read operation will complete
799 immediately without blocking (unless the {\bf wxSOCKET\_WAITALL} flag
800 is set, in which case the operation might still block).
801
802 \wxheading{Parameters}
803
804 \docparam{seconds}{Number of seconds to wait.
805 If -1, it will wait for the default timeout,
806 as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
807
808 \docparam{millisecond}{Number of milliseconds to wait.}
809
810 \wxheading{Return value}
811
812 Returns TRUE if the socket becomes readable, FALSE on timeout.
813
814 \wxheading{See also}
815
816 \helpref{wxSocketBase::Wait}{wxsocketbasewait},
817 \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite},
818 \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost}
819
820 %
821 % WaitForWrite
822 %
823 \membersection{wxSocketBase::WaitForWrite}\label{wxsocketbasewaitforwrite}
824
825 \func{bool}{WaitForWrite}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
826
827 This function waits until the socket becomes writable. This might mean that
828 the socket is ready to send new data, or for streamed sockets, that the
829 connection has been closed, so that a write operation is guaranteed to
830 complete immediately (unless the {\bf wxSOCKET\_WAITALL} flag is set,
831 in which case the operation might still block).
832
833 \wxheading{Parameters}
834
835 \docparam{seconds}{Number of seconds to wait.
836 If -1, it will wait for the default timeout,
837 as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
838
839 \docparam{millisecond}{Number of milliseconds to wait.}
840
841 \wxheading{Return value}
842
843 Returns TRUE if the socket becomes writable, FALSE on timeout.
844
845 \wxheading{See also}
846
847 \helpref{wxSocketBase::Wait}{wxsocketbasewait},
848 \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread},
849 \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost}
850
851 %
852 % WaitForLost
853 %
854 \membersection{wxSocketBase::WaitForLost}\label{wxsocketbasewaitforlost}
855
856 \func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
857
858 This function waits until the connection is lost. This may happen if
859 the peer gracefully closes the connection or if the connection breaks.
860
861 \wxheading{Parameters}
862
863 \docparam{seconds}{Number of seconds to wait.
864 If -1, it will wait for the default timeout,
865 as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
866
867 \docparam{millisecond}{Number of milliseconds to wait.}
868
869 \wxheading{Return value}
870
871 Returns TRUE if the connection was lost, FALSE if the timeout was reached.
872
873 \wxheading{See also}
874
875 \helpref{wxSocketBase::WaitForRead}{wxsocketbasewaitforread},
876 \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite},
877 \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost}
878
879 %
880 % Write
881 %
882 \membersection{wxSocketBase::Write}\label{wxsocketbasewrite}
883
884 \func{wxSocketBase\&}{Write}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}}
885
886 This function writes a buffer of {\it nbytes} bytes to the socket.
887
888 Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually written.
889
890 Use \helpref{Error}{wxsocketbaseerror} to determine if the operation succeeded.
891
892 \wxheading{Parameters}
893
894 \docparam{buffer}{Buffer with the data to be sent.}
895
896 \docparam{nbytes}{Number of bytes.}
897
898 \wxheading{Return value}
899
900 Returns a reference to the current object.
901
902 \wxheading{Remark/Warning}
903
904 The exact behaviour of wxSocketBase::Write depends on the combination
905 of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
906
907 \wxheading{See also}
908
909 \helpref{wxSocketBase::Error}{wxsocketbaseerror},
910 \helpref{wxSocketBase::LastError}{wxsocketbaselasterror},
911 \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount},
912 \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}
913
914 %
915 % WriteMsg
916 %
917 \membersection{wxSocketBase::WriteMsg}\label{wxsocketbasewritemsg}
918
919 \func{wxSocketBase\&}{WriteMsg}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}}
920
921 This function writes a buffer of {\it nbytes} bytes from the socket, but it
922 writes a short header before so that \helpref{ReadMsg}{wxsocketbasereadmsg}
923 knows how much data should it actually read. So, a buffer sent with WriteMsg
924 {\bf must} be read with ReadMsg. This function always waits for the entire
925 buffer to be sent, unless an error occurs.
926
927 Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually written.
928
929 Use \helpref{Error}{wxsocketbaseerror} to determine if the operation succeeded.
930
931 \wxheading{Parameters}
932
933 \docparam{buffer}{Buffer with the data to be sent.}
934
935 \docparam{nbytes}{Number of bytes to send.}
936
937 \wxheading{Return value}
938
939 Returns a reference to the current object.
940
941 \wxheading{Remark/Warning}
942
943 wxSocketBase::WriteMsg will behave as if the {\bf wxSOCKET\_WAITALL} flag
944 was always set and it will always ignore the {\bf wxSOCKET\_NOWAIT} flag.
945 The exact behaviour of WriteMsg depends on the {\bf wxSOCKET\_BLOCK} flag.
946 For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
947
948 \wxheading{See also}
949
950 \helpref{wxSocketBase::Error}{wxsocketbaseerror},
951 \helpref{wxSocketBase::LastError}{wxsocketbaselasterror},
952 \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount},
953 \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags},
954 \helpref{wxSocketBase::ReadMsg}{wxsocketbasereadmsg}
955
956
957 % ---------------------------------------------------------------------------
958 % CLASS wxSocketClient
959 % ---------------------------------------------------------------------------
960
961 \section{\class{wxSocketClient}}\label{wxsocketclient}
962
963 \wxheading{Derived from}
964
965 \helpref{wxSocketBase}{wxsocketbase}
966
967 \wxheading{Include files}
968
969 <wx/socket.h>
970
971 % ---------------------------------------------------------------------------
972 % Members
973 % ---------------------------------------------------------------------------
974 %
975 % wxSocketClient
976 %
977 \membersection{wxSocketClient::wxSocketClient}
978
979 \func{}{wxSocketClient}{\param{wxSockFlags}{ flags = wxSocketBase::NONE}}
980
981 Constructor.
982
983 \wxheading{Parameters}
984
985 \docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})}
986
987 %
988 % ~wxSocketClient
989 %
990 \membersection{wxSocketClient::\destruct{wxSocketClient}}
991
992 \func{}{\destruct{wxSocketClient}}{\void}
993
994 Destructor.
995
996 %
997 % Connect
998 %
999 \membersection{wxSocketClient::Connect}\label{wxsocketclientconnect}
1000
1001 \func{bool}{Connect}{\param{wxSockAddress\&}{ address}, \param{bool}{ wait = TRUE}}
1002
1003 Connects to a server using the specified address.
1004
1005 If {\it wait} is TRUE, Connect will wait until the connection completes.
1006 {\bf Warning:} This will block the GUI.
1007
1008 If {\it wait} is FALSE, Connect will try to establish the connection and
1009 return immediately, without blocking the GUI. When used this way, even if
1010 Connect returns FALSE, the connection request can be completed later.
1011 To detect this, use \helpref{WaitOnConnect}{wxsocketclientwaitonconnect},
1012 or catch {\bf wxSOCKET\_CONNECTION} events (for successful establishment)
1013 and {\bf wxSOCKET\_LOST} events (for connection failure).
1014
1015 \wxheading{Parameters}
1016
1017 \docparam{address}{Address of the server.}
1018
1019 \docparam{wait}{If TRUE, waits for the connection to complete.}
1020
1021 \wxheading{Return value}
1022
1023 Returns TRUE if the connection is established and no error occurs.
1024
1025 If {\it wait} was TRUE, and Connect returns FALSE, an error occured
1026 and the connection failed.
1027
1028 If {\it wait} was FALSE, and Connect returns FALSE, you should still
1029 be prepared to handle the completion of this connection request, either
1030 with \helpref{WaitOnConnect}{wxsocketclientwaitonconnect} or by watching
1031 {\bf wxSOCKET\_CONNECTION} and {\bf wxSOCKET\_LOST} events.
1032
1033 \wxheading{See also}
1034
1035 \helpref{wxSocketClient::WaitOnConnect}{wxsocketclientwaitonconnect},
1036 \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify},
1037 \helpref{wxSocketBase::Notify}{wxsocketbasenotify}
1038
1039 %
1040 % WaitOnConnect
1041 %
1042 \membersection{wxSocketClient::WaitOnConnect}\label{wxsocketclientwaitonconnect}
1043
1044 \func{bool}{WaitOnConnect}{\param{long}{ seconds = -1}, \param{long}{ milliseconds = 0}}
1045
1046 Wait until a connection request completes, or until the specified timeout
1047 elapses. Use this function after issuing a call to \helpref{Connect}{wxsocketclientconnect}
1048 with {\it wait} set to FALSE.
1049
1050 \wxheading{Parameters}
1051
1052 \docparam{seconds}{Number of seconds to wait.
1053 If -1, it will wait for the default timeout,
1054 as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
1055
1056 \docparam{millisecond}{Number of milliseconds to wait.}
1057
1058 \wxheading{Return value}
1059
1060 WaitOnConnect returns TRUE if the connection request completes. This
1061 does not necessarily mean that the connection was succesfully established;
1062 it might also happen that the connection was refused by the peer. Use
1063 \helpref{IsConnected}{wxsocketbaseisconnected} to distinguish between
1064 these two situations.
1065
1066 If the timeout elapses, WaitOnConnect returns FALSE.
1067
1068 These semantics allow code like this:
1069
1070 \begin{verbatim}
1071 // Issue the connection request
1072 client->Connect(addr, FALSE);
1073
1074 // Wait until the request completes or until we decide to give up
1075 bool waitmore = TRUE;
1076 while ( !client->WaitOnConnect(seconds, millis) && waitmore )
1077 {
1078 // possibly give some feedback to the user,
1079 // and update waitmore if needed.
1080 }
1081 bool success = client->IsConnected();
1082 \end{verbatim}
1083
1084 \wxheading{See also}
1085
1086 \helpref{wxSocketClient::Connect}{wxsocketclientconnect},
1087 \helpref{wxSocketBase::IsConnected}{wxsocketbaseisconnected}
1088
1089 % ---------------------------------------------------------------------------
1090 % CLASS: wxSocketEvent
1091 % ---------------------------------------------------------------------------
1092 \section{\class{wxSocketEvent}}\label{wxsocketevent}
1093
1094 This event class contains information about socket events.
1095
1096 \wxheading{Derived from}
1097
1098 \helpref{wxEvent}{wxevent}
1099
1100 \wxheading{Include files}
1101
1102 <wx/socket.h>
1103
1104 \wxheading{Event table macros}
1105
1106 To process a socket event, use these event handler macros to direct input to member
1107 functions that take a wxSocketEvent argument.
1108
1109 \twocolwidtha{7cm}
1110 \begin{twocollist}\itemsep=0pt
1111 \twocolitem{{\bf EVT\_SOCKET(id, func)}}{Process a socket event, supplying the member function.}
1112 \end{twocollist}
1113
1114 \wxheading{See also}
1115
1116 \helpref{wxSocketBase}{wxsocketbase},
1117 \helpref{wxSocketClient}{wxsocketclient},
1118 \helpref{wxSocketServer}{wxsocketserver}
1119
1120 \latexignore{\rtfignore{\wxheading{Members}}}
1121
1122 \membersection{wxSocketEvent::wxSocketEvent}
1123
1124 \func{}{wxSocketEvent}{\param{int}{ id = 0}}
1125
1126 Constructor.
1127
1128 \membersection{wxSocketEvent::Socket}\label{wxsocketeventsocket}
1129
1130 \constfunc{wxSocketBase *}{Socket}{\void}
1131
1132 Returns the socket object to which this event refers to. This makes
1133 it possible to use the same event handler for different sockets.
1134
1135 \membersection{wxSocketEvent::SocketEvent}\label{wxsocketeventsocketevent}
1136
1137 \constfunc{wxSocketNotify}{SocketEvent}{\void}
1138
1139 Returns the socket event type.
1140
1141 % ---------------------------------------------------------------------------
1142 % CLASS: wxSocketServer
1143 % ---------------------------------------------------------------------------
1144 \section{\class{wxSocketServer}}\label{wxsocketserver}
1145
1146 \wxheading{Derived from}
1147
1148 \helpref{wxSocketBase}{wxsocketbase}
1149
1150 \wxheading{Include files}
1151
1152 <wx/socket.h>
1153
1154 % ---------------------------------------------------------------------------
1155 % Members
1156 % ---------------------------------------------------------------------------
1157 \latexignore{\rtfignore{\wxheading{Members}}}
1158
1159 %
1160 % wxSocketServer
1161 %
1162 \membersection{wxSocketServer::wxSocketServer}\label{wxsocketserverconstr}
1163
1164 \func{}{wxSocketServer}{\param{wxSockAddress\&}{ address}, \param{wxSockFlags}{ flags = wxSocketBase::NONE}}
1165
1166 Constructs a new server and tries to bind to the specified {\it address}.
1167 Before trying to accept new connections, test whether it succeeded with
1168 \helpref{wxSocketBase::Ok}{wxsocketbaseok}.
1169
1170 \wxheading{Parameters}
1171
1172 \docparam{address}{Specifies the local address for the server (e.g. port number).}
1173
1174 \docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})}
1175
1176 %
1177 % ~wxSocketServer
1178 %
1179 \membersection{wxSocketServer::\destruct{wxSocketServer}}
1180
1181 \func{}{\destruct{wxSocketServer}}{\void}
1182
1183 Destructor (it doesn't close the accepted connections).
1184
1185 %
1186 % Accept
1187 %
1188 \membersection{wxSocketServer::Accept}\label{wxsocketserveraccept}
1189
1190 \func{wxSocketBase *}{Accept}{\param{bool}{ wait = TRUE}}
1191
1192 Accepts an incoming connection request, and creates a new
1193 \helpref{wxSocketBase}{wxsocketbase} object which represents
1194 the server-side of the connection.
1195
1196 If {\it wait} is TRUE and there are no pending connections to be
1197 accepted, it will wait for the next incoming connection to arrive.
1198 {\bf Warning:} This will block the GUI.
1199
1200 If {\it wait} is FALSE, it will try to accept a pending connection
1201 if there is one, but it will always return immediately without blocking
1202 the GUI. If you want to use Accept in this way, you can either check for
1203 incoming connections with \helpref{WaitForAccept}{wxsocketserverwaitforaccept}
1204 or catch {\bf wxSOCKET\_CONNECTION} events, then call Accept once you know
1205 that there is an incoming connection waiting to be accepted.
1206
1207 \wxheading{Return value}
1208
1209 Returns an opened socket connection, or NULL if an error occured or
1210 if the {\it wait} parameter was FALSE and there were no pending
1211 connections.
1212
1213 \wxheading{See also}
1214
1215 \helpref{wxSocketServer::WaitForAccept}{wxsocketserverwaitforaccept},
1216 \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify},
1217 \helpref{wxSocketBase::Notify}{wxsocketbasenotify},
1218 \helpref{wxSocketServer::AcceptWith}{wxsocketserveracceptwith}
1219
1220 %
1221 % AcceptWith
1222 %
1223 \membersection{wxSocketServer::AcceptWith}\label{wxsocketserveracceptwith}
1224
1225 \func{bool}{AcceptWith}{\param{wxSocketBase\&}{ socket}, \param{bool}{ wait = TRUE}}
1226
1227 Accept an incoming connection using the specified socket object.
1228
1229 \wxheading{Parameters}
1230
1231 \docparam{socket}{Socket to be initialized}
1232
1233 \wxheading{Return value}
1234
1235 Returns TRUE on success, or FALSE if an error occured or if the
1236 {\it wait} parameter was FALSE and there were no pending
1237 connections.
1238
1239 \helpref{wxSocketServer::WaitForAccept}{wxsocketserverwaitforaccept},
1240 \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify},
1241 \helpref{wxSocketBase::Notify}{wxsocketbasenotify},
1242 \helpref{wxSocketServer::Accept}{wxsocketserveraccept} for a detailed explanation
1243
1244 %
1245 % WaitForAccept
1246 %
1247 \membersection{wxSocketServer::WaitForAccept}\label{wxsocketserverwaitforaccept}
1248
1249 \func{bool}{WaitForAccept}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
1250
1251 This function waits for an incoming connection. Use it if you want to call
1252 \helpref{Accept}{wxsocketserveraccept} or \helpref{AcceptWith}{wxsocketserveracceptwith}
1253 with {\it wait} set to FALSE, to detect when an incoming connection is waiting
1254 to be accepted.
1255
1256 \wxheading{Parameters}
1257
1258 \docparam{seconds}{Number of seconds to wait.
1259 If -1, it will wait for the default timeout,
1260 as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
1261
1262 \docparam{millisecond}{Number of milliseconds to wait.}
1263
1264 \wxheading{Return value}
1265
1266 Returns TRUE if an incoming connection arrived, FALSE if the timeout elapsed.
1267
1268 \wxheading{See also}
1269
1270 \helpref{wxSocketServer::Accept}{wxsocketserveraccept},
1271 \helpref{wxSocketServer::AcceptWith}{wxsocketserveracceptwith}
1272