2002-01-14 11:40:44 -05:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%% Name: socket.tex
|
|
|
|
%% Purpose: wxSocket docs
|
|
|
|
%% Author: Guillermo Rodriguez Garcia <guille@iies.es>
|
|
|
|
%% Modified by:
|
|
|
|
%% Created: 14.01.02 (extracted from socket.tex)
|
|
|
|
%% RCS-ID: $Id$
|
2004-05-04 04:27:20 -04:00
|
|
|
%% Copyright: (c) wxWidgets team
|
2005-02-22 10:09:56 -05:00
|
|
|
%% License: wxWindows license
|
2002-01-14 11:40:44 -05:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
% ---------------------------------------------------------------------------
|
|
|
|
% CLASS: wxSocketServer
|
|
|
|
% ---------------------------------------------------------------------------
|
|
|
|
\section{\class{wxSocketServer}}\label{wxsocketserver}
|
|
|
|
|
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
\helpref{wxSocketBase}{wxsocketbase}
|
|
|
|
|
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/socket.h>
|
|
|
|
|
|
|
|
% ---------------------------------------------------------------------------
|
|
|
|
% Members
|
|
|
|
% ---------------------------------------------------------------------------
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
|
|
|
%
|
|
|
|
% wxSocketServer
|
|
|
|
%
|
2004-09-24 06:57:56 -04:00
|
|
|
\membersection{wxSocketServer::wxSocketServer}\label{wxsocketserverctor}
|
2002-01-14 11:40:44 -05:00
|
|
|
|
|
|
|
\func{}{wxSocketServer}{\param{wxSockAddress\&}{ address}, \param{wxSocketFlags}{ flags = wxSOCKET\_NONE}}
|
|
|
|
|
|
|
|
Constructs a new server and tries to bind to the specified {\it address}.
|
|
|
|
Before trying to accept new connections, test whether it succeeded with
|
|
|
|
\helpref{wxSocketBase::Ok}{wxsocketbaseok}.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{address}{Specifies the local address for the server (e.g. port number).}
|
|
|
|
|
|
|
|
\docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})}
|
|
|
|
|
|
|
|
%
|
|
|
|
% ~wxSocketServer
|
|
|
|
%
|
2004-09-24 06:57:56 -04:00
|
|
|
\membersection{wxSocketServer::\destruct{wxSocketServer}}\label{wxsocketserverdtor}
|
2002-01-14 11:40:44 -05:00
|
|
|
|
|
|
|
\func{}{\destruct{wxSocketServer}}{\void}
|
|
|
|
|
|
|
|
Destructor (it doesn't close the accepted connections).
|
|
|
|
|
|
|
|
%
|
|
|
|
% Accept
|
|
|
|
%
|
|
|
|
\membersection{wxSocketServer::Accept}\label{wxsocketserveraccept}
|
|
|
|
|
2003-01-17 19:16:34 -05:00
|
|
|
\func{wxSocketBase *}{Accept}{\param{bool}{ wait = true}}
|
2002-01-14 11:40:44 -05:00
|
|
|
|
|
|
|
Accepts an incoming connection request, and creates a new
|
|
|
|
\helpref{wxSocketBase}{wxsocketbase} object which represents
|
|
|
|
the server-side of the connection.
|
|
|
|
|
2003-01-17 19:16:34 -05:00
|
|
|
If {\it wait} is true and there are no pending connections to be
|
2002-01-14 11:40:44 -05:00
|
|
|
accepted, it will wait for the next incoming connection to
|
|
|
|
arrive. {\bf Warning:} This will block the GUI.
|
|
|
|
|
2003-01-17 19:16:34 -05:00
|
|
|
If {\it wait} is false, it will try to accept a pending connection
|
2002-01-14 11:40:44 -05:00
|
|
|
if there is one, but it will always return immediately without blocking
|
|
|
|
the GUI. If you want to use Accept in this way, you can either check for
|
|
|
|
incoming connections with \helpref{WaitForAccept}{wxsocketserverwaitforaccept}
|
|
|
|
or catch {\bf wxSOCKET\_CONNECTION} events, then call Accept once you know
|
|
|
|
that there is an incoming connection waiting to be accepted.
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
|
|
|
Returns an opened socket connection, or NULL if an error occurred or
|
2003-01-17 19:16:34 -05:00
|
|
|
if the {\it wait} parameter was false and there were no pending
|
2002-01-14 11:40:44 -05:00
|
|
|
connections.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxSocketServer::WaitForAccept}{wxsocketserverwaitforaccept},
|
|
|
|
\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify},
|
|
|
|
\helpref{wxSocketBase::Notify}{wxsocketbasenotify},
|
|
|
|
\helpref{wxSocketServer::AcceptWith}{wxsocketserveracceptwith}
|
|
|
|
|
|
|
|
%
|
|
|
|
% AcceptWith
|
|
|
|
%
|
|
|
|
\membersection{wxSocketServer::AcceptWith}\label{wxsocketserveracceptwith}
|
|
|
|
|
2003-01-17 19:16:34 -05:00
|
|
|
\func{bool}{AcceptWith}{\param{wxSocketBase\&}{ socket}, \param{bool}{ wait = true}}
|
2002-01-14 11:40:44 -05:00
|
|
|
|
|
|
|
Accept an incoming connection using the specified socket object.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{socket}{Socket to be initialized}
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
2003-01-17 19:16:34 -05:00
|
|
|
Returns true on success, or false if an error occurred or if the
|
|
|
|
{\it wait} parameter was false and there were no pending
|
2002-01-14 11:40:44 -05:00
|
|
|
connections.
|
|
|
|
|
|
|
|
\helpref{wxSocketServer::WaitForAccept}{wxsocketserverwaitforaccept},
|
|
|
|
\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify},
|
|
|
|
\helpref{wxSocketBase::Notify}{wxsocketbasenotify},
|
|
|
|
\helpref{wxSocketServer::Accept}{wxsocketserveraccept}
|
|
|
|
|
|
|
|
%
|
|
|
|
% WaitForAccept
|
|
|
|
%
|
|
|
|
\membersection{wxSocketServer::WaitForAccept}\label{wxsocketserverwaitforaccept}
|
|
|
|
|
|
|
|
\func{bool}{WaitForAccept}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
|
|
|
|
|
|
|
|
This function waits for an incoming connection. Use it if you want to call
|
|
|
|
\helpref{Accept}{wxsocketserveraccept} or \helpref{AcceptWith}{wxsocketserveracceptwith}
|
2003-01-17 19:16:34 -05:00
|
|
|
with {\it wait} set to false, to detect when an incoming connection is waiting
|
2002-01-14 11:40:44 -05:00
|
|
|
to be accepted.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{seconds}{Number of seconds to wait.
|
|
|
|
If -1, it will wait for the default timeout,
|
|
|
|
as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
|
|
|
|
|
|
|
|
\docparam{millisecond}{Number of milliseconds to wait.}
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
2003-01-17 19:16:34 -05:00
|
|
|
Returns true if an incoming connection arrived, false if the timeout elapsed.
|
2002-01-14 11:40:44 -05:00
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxSocketServer::Accept}{wxsocketserveraccept},
|
|
|
|
\helpref{wxSocketServer::AcceptWith}{wxsocketserveracceptwith},
|
|
|
|
\helpref{wxSocketBase::InterruptWait}{wxsocketbaseinterruptwait}
|
|
|
|
|
|
|
|
|