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