1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxSocket docs
4 %% Author: Guillermo Rodriguez Garcia <guille@iies.es>
6 %% Created: 14.01.02 (extracted from socket.tex)
8 %% Copyright: (c) wxWidgets team
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 % ---------------------------------------------------------------------------
13 % CLASS: wxSocketServer
14 % ---------------------------------------------------------------------------
15 \section{\class{wxSocketServer
}}\label{wxsocketserver
}
17 \wxheading{Derived from
}
19 \helpref{wxSocketBase
}{wxsocketbase
}\\
20 \helpref{wxObject
}{wxobject
}
22 \wxheading{Include files
}
28 \helpref{wxNet
}{librarieslist
}
30 % ---------------------------------------------------------------------------
32 % ---------------------------------------------------------------------------
33 \latexignore{\rtfignore{\wxheading{Members
}}}
38 \membersection{wxSocketServer::wxSocketServer
}\label{wxsocketserverctor
}
40 \func{}{wxSocketServer
}{\param{const wxSockAddress\&
}{ address
},
\param{wxSocketFlags
}{ flags = wxSOCKET
\_NONE}}
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
44 \helpref{wxSocketBase:IsOk
}{wxsocketbaseisok
}.
46 \wxheading{Parameters
}
48 \docparam{address
}{Specifies the local address for the server (e.g. port number).
}
50 \docparam{flags
}{Socket flags (See
\helpref{wxSocketBase::SetFlags
}{wxsocketbasesetflags
})
}
55 \membersection{wxSocketServer::
\destruct{wxSocketServer
}}\label{wxsocketserverdtor
}
57 \func{}{\destruct{wxSocketServer
}}{\void}
59 Destructor (it doesn't close the accepted connections).
64 \membersection{wxSocketServer::Accept
}\label{wxsocketserveraccept
}
66 \func{wxSocketBase *
}{Accept
}{\param{bool
}{ wait = true
}}
68 Accepts an incoming connection request, and creates a new
69 \helpref{wxSocketBase
}{wxsocketbase
} object which represents
70 the server-side of the connection.
72 If
{\it wait
} is true and there are no pending connections to be
73 accepted, it will wait for the next incoming connection to
74 arrive.
{\bf Warning:
} This will block the GUI.
76 If
{\it wait
} is false, it will try to accept a pending connection
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.
83 \wxheading{Return value
}
85 Returns an opened socket connection, or NULL if an error occurred or
86 if the
{\it wait
} parameter was false and there were no pending
91 \helpref{wxSocketServer::WaitForAccept
}{wxsocketserverwaitforaccept
},
92 \helpref{wxSocketBase::SetNotify
}{wxsocketbasesetnotify
},
93 \helpref{wxSocketBase::Notify
}{wxsocketbasenotify
},
94 \helpref{wxSocketServer::AcceptWith
}{wxsocketserveracceptwith
}
99 \membersection{wxSocketServer::AcceptWith
}\label{wxsocketserveracceptwith
}
101 \func{bool
}{AcceptWith
}{\param{wxSocketBase\&
}{ socket
},
\param{bool
}{ wait = true
}}
103 Accept an incoming connection using the specified socket object.
105 \wxheading{Parameters
}
107 \docparam{socket
}{Socket to be initialized
}
109 \wxheading{Return value
}
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
115 \helpref{wxSocketServer::WaitForAccept
}{wxsocketserverwaitforaccept
},
116 \helpref{wxSocketBase::SetNotify
}{wxsocketbasesetnotify
},
117 \helpref{wxSocketBase::Notify
}{wxsocketbasenotify
},
118 \helpref{wxSocketServer::Accept
}{wxsocketserveraccept
}
123 \membersection{wxSocketServer::WaitForAccept
}\label{wxsocketserverwaitforaccept
}
125 \func{bool
}{WaitForAccept
}{\param{long
}{ seconds = -
1},
\param{long
}{ millisecond =
0}}
127 This function waits for an incoming connection. Use it if you want to call
128 \helpref{Accept
}{wxsocketserveraccept
} or
\helpref{AcceptWith
}{wxsocketserveracceptwith
}
129 with
{\it wait
} set to false, to detect when an incoming connection is waiting
132 \wxheading{Parameters
}
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
}.
}
138 \docparam{millisecond
}{Number of milliseconds to wait.
}
140 \wxheading{Return value
}
142 Returns true if an incoming connection arrived, false if the timeout elapsed.
146 \helpref{wxSocketServer::Accept
}{wxsocketserveraccept
},
147 \helpref{wxSocketServer::AcceptWith
}{wxsocketserveracceptwith
},
148 \helpref{wxSocketBase::InterruptWait
}{wxsocketbaseinterruptwait
}