]>
Commit | Line | Data |
---|---|---|
f3845e88 VZ |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: socket.tex | |
3 | %% Purpose: wxSocket docs | |
4 | %% Author: Guillermo Rodriguez Garcia <guille@iies.es> | |
5 | %% Modified by: | |
6 | %% Created: 14.01.02 (extracted from socket.tex) | |
7 | %% RCS-ID: $Id$ | |
fc2171bd | 8 | %% Copyright: (c) wxWidgets team |
8795498c | 9 | %% License: wxWindows license |
f3845e88 VZ |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
11 | ||
12 | % --------------------------------------------------------------------------- | |
13 | % CLASS: wxSocketServer | |
14 | % --------------------------------------------------------------------------- | |
15 | \section{\class{wxSocketServer}}\label{wxsocketserver} | |
16 | ||
17 | \wxheading{Derived from} | |
18 | ||
7376079d VZ |
19 | \helpref{wxSocketBase}{wxsocketbase}\\ |
20 | \helpref{wxObject}{wxobject} | |
f3845e88 VZ |
21 | |
22 | \wxheading{Include files} | |
23 | ||
24 | <wx/socket.h> | |
25 | ||
a7af285d VZ |
26 | \wxheading{Library} |
27 | ||
28 | \helpref{wxNet}{librarieslist} | |
29 | ||
f3845e88 VZ |
30 | % --------------------------------------------------------------------------- |
31 | % Members | |
32 | % --------------------------------------------------------------------------- | |
33 | \latexignore{\rtfignore{\wxheading{Members}}} | |
34 | ||
35 | % | |
36 | % wxSocketServer | |
37 | % | |
39275175 | 38 | \membersection{wxSocketServer::wxSocketServer}\label{wxsocketserverctor} |
f3845e88 | 39 | |
fbfb8bcc | 40 | \func{}{wxSocketServer}{\param{const wxSockAddress\&}{ address}, \param{wxSocketFlags}{ flags = wxSOCKET\_NONE}} |
f3845e88 VZ |
41 | |
42 | Constructs a new server and tries to bind to the specified {\it address}. | |
43 | Before trying to accept new connections, test whether it succeeded with | |
b7cacb43 | 44 | \helpref{wxSocketBase:IsOk}{wxsocketbaseisok}. |
f3845e88 VZ |
45 | |
46 | \wxheading{Parameters} | |
47 | ||
48 | \docparam{address}{Specifies the local address for the server (e.g. port number).} | |
49 | ||
50 | \docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})} | |
51 | ||
52 | % | |
53 | % ~wxSocketServer | |
54 | % | |
39275175 | 55 | \membersection{wxSocketServer::\destruct{wxSocketServer}}\label{wxsocketserverdtor} |
f3845e88 VZ |
56 | |
57 | \func{}{\destruct{wxSocketServer}}{\void} | |
58 | ||
59 | Destructor (it doesn't close the accepted connections). | |
60 | ||
61 | % | |
62 | % Accept | |
63 | % | |
64 | \membersection{wxSocketServer::Accept}\label{wxsocketserveraccept} | |
65 | ||
cc81d32f | 66 | \func{wxSocketBase *}{Accept}{\param{bool}{ wait = true}} |
f3845e88 VZ |
67 | |
68 | Accepts an incoming connection request, and creates a new | |
69 | \helpref{wxSocketBase}{wxsocketbase} object which represents | |
70 | the server-side of the connection. | |
71 | ||
cc81d32f | 72 | If {\it wait} is true and there are no pending connections to be |
f3845e88 VZ |
73 | accepted, it will wait for the next incoming connection to |
74 | arrive. {\bf Warning:} This will block the GUI. | |
75 | ||
cc81d32f | 76 | If {\it wait} is false, it will try to accept a pending connection |
f3845e88 VZ |
77 | if there is one, but it will always return immediately without blocking |
78 | the GUI. If you want to use Accept in this way, you can either check for | |
79 | incoming connections with \helpref{WaitForAccept}{wxsocketserverwaitforaccept} | |
80 | or catch {\bf wxSOCKET\_CONNECTION} events, then call Accept once you know | |
81 | that there is an incoming connection waiting to be accepted. | |
82 | ||
83 | \wxheading{Return value} | |
84 | ||
85 | Returns an opened socket connection, or NULL if an error occurred or | |
cc81d32f | 86 | if the {\it wait} parameter was false and there were no pending |
f3845e88 VZ |
87 | connections. |
88 | ||
89 | \wxheading{See also} | |
90 | ||
91 | \helpref{wxSocketServer::WaitForAccept}{wxsocketserverwaitforaccept}, | |
92 | \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, | |
93 | \helpref{wxSocketBase::Notify}{wxsocketbasenotify}, | |
94 | \helpref{wxSocketServer::AcceptWith}{wxsocketserveracceptwith} | |
95 | ||
96 | % | |
97 | % AcceptWith | |
98 | % | |
99 | \membersection{wxSocketServer::AcceptWith}\label{wxsocketserveracceptwith} | |
100 | ||
cc81d32f | 101 | \func{bool}{AcceptWith}{\param{wxSocketBase\&}{ socket}, \param{bool}{ wait = true}} |
f3845e88 VZ |
102 | |
103 | Accept an incoming connection using the specified socket object. | |
104 | ||
105 | \wxheading{Parameters} | |
106 | ||
107 | \docparam{socket}{Socket to be initialized} | |
108 | ||
109 | \wxheading{Return value} | |
110 | ||
cc81d32f VS |
111 | Returns true on success, or false if an error occurred or if the |
112 | {\it wait} parameter was false and there were no pending | |
f3845e88 VZ |
113 | connections. |
114 | ||
115 | \helpref{wxSocketServer::WaitForAccept}{wxsocketserverwaitforaccept}, | |
116 | \helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, | |
117 | \helpref{wxSocketBase::Notify}{wxsocketbasenotify}, | |
118 | \helpref{wxSocketServer::Accept}{wxsocketserveraccept} | |
119 | ||
120 | % | |
121 | % WaitForAccept | |
122 | % | |
123 | \membersection{wxSocketServer::WaitForAccept}\label{wxsocketserverwaitforaccept} | |
124 | ||
125 | \func{bool}{WaitForAccept}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}} | |
126 | ||
127 | This function waits for an incoming connection. Use it if you want to call | |
128 | \helpref{Accept}{wxsocketserveraccept} or \helpref{AcceptWith}{wxsocketserveracceptwith} | |
cc81d32f | 129 | with {\it wait} set to false, to detect when an incoming connection is waiting |
f3845e88 VZ |
130 | to be accepted. |
131 | ||
132 | \wxheading{Parameters} | |
133 | ||
134 | \docparam{seconds}{Number of seconds to wait. | |
135 | If -1, it will wait for the default timeout, | |
136 | as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.} | |
137 | ||
138 | \docparam{millisecond}{Number of milliseconds to wait.} | |
139 | ||
140 | \wxheading{Return value} | |
141 | ||
cc81d32f | 142 | Returns true if an incoming connection arrived, false if the timeout elapsed. |
f3845e88 VZ |
143 | |
144 | \wxheading{See also} | |
145 | ||
146 | \helpref{wxSocketServer::Accept}{wxsocketserveraccept}, | |
147 | \helpref{wxSocketServer::AcceptWith}{wxsocketserveracceptwith}, | |
148 | \helpref{wxSocketBase::InterruptWait}{wxsocketbaseinterruptwait} | |
149 | ||
150 |