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