X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aed0ed3c420d6821e81ca6243482e620c4aeeffd..45fcbf3b7a7c9cfd96e67278e4eaa12e8e015651:/docs/latex/wx/socket.tex

diff --git a/docs/latex/wx/socket.tex b/docs/latex/wx/socket.tex
index f4e8f7df05..26fb37c2d3 100644
--- a/docs/latex/wx/socket.tex
+++ b/docs/latex/wx/socket.tex
@@ -4,6 +4,36 @@
 
 \helpref{wxEvtHandler}{wxevthandler}
 
+\wxheading{Include files}
+
+<wx/socket.h>
+
+\wxheading{wxSocket errors}%\label{wxsocketerrs} % Labels don't work on a non-section!
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf wxSOCKET\_NOERROR}}{No error happened.}
+\twocolitem{{\bf wxSOCKET\_INVOP}}{Invalid operation.}
+\twocolitem{{\bf wxSOCKET\_IOERR}}{Input/Output error.}
+\twocolitem{{\bf wxSOCKET\_INVADDR}}{Invalid address passed to wxSocket.}
+\twocolitem{{\bf wxSOCKET\_INVSOCK}}{Invalid socket (uninitialized).}
+\twocolitem{{\bf wxSOCKET\_NOHOST}}{No corresponding host.}
+\twocolitem{{\bf wxSOCKET\_INVPORT}}{Invalid port.}
+\twocolitem{{\bf wxSOCKET\_TRYAGAIN}}{The IO call has a timeout or is in non-blocking mode.}
+\twocolitem{{\bf wxSOCKET\_MEMERR}}{Memory exhausted.}
+\end{twocollist}%
+
+\wxheading{wxSocket events}
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf wxSOCKET\_INPUT}}{Some data are ready to be got.}
+\twocolitem{{\bf wxSOCKET\_OUTPUT}}{The socket is ready to be written to.}
+\twocolitem{{\bf wxSOCKET\_CONNECTION}}{Someone want to connect our server.}
+\twocolitem{{\bf wxSOCKET\_LOST}}{The connection has been broken.}
+\twocolitem{{\bf wxSOCKET\_MAX\_EVENT}}{This should never happen but the compiler may complain about it.}
+\end{twocollist}%
+
 % ---------------------------------------------------------------------------
 % Event handling
 % ---------------------------------------------------------------------------
@@ -49,6 +79,72 @@ Destroys the wxSocketBase object.
 % State functions
 % ---------------------------------------------------------------------------
 
+%
+% SetFlags
+%
+
+\membersection{wxSocketBase::SetFlags}\label{wxsocketbasesetflags}
+
+\func{void}{SetFlags}{\param{wxSocketBase::wxSockFlags}{ flags}}
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf wxSocketBase::NONE}}{Normal functionnalities.}
+\twocolitem{{\bf wxSocketBase::NOWAIT}}{Get the available data in the input queue and exit immediately.}
+\twocolitem{{\bf wxSocketBase::WAITALL}}{Wait for all required data unless an error occured.}
+\twocolitem{{\bf wxSocketBase::SPEED}}{Disable the asynchronous IO functionnality.}
+\end{twocollist}
+
+%
+% SetNotify
+%
+\membersection{wxSocketBase::SetNotify}\label{wxsocketbasesetnotify}
+
+\func{void}{SetNotify}{\param{wxSocketEventFlags}{ event_flags}}
+
+SetNotify setups which socket events are to be sent to the event handler.
+You specify in parameters a mask of wxSocket events. The flags is:
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf wxSOCKET\_INPUT\_FLAG}}{to receive wxSOCKET_INPUT}
+\twocolitem{{\bf wxSOCKET\_OUTPUT\_FLAG}}{to receive wxSOCKET_OUTPUT}
+\twocolitem{{\bf wxSOCKET\_CONNECTION\_FLAG}}{to receive wxSOCKET_CONNECTION}
+\twocolitem{{\bf wxSOCKET\_LOST\_FLAG}}{to receive wxSOCKET_LOST}
+\end{twocollist}%
+
+For example:
+\begin{verbatim}
+  sock.SetNotify(wxSOCKET\_INPUT\_FLAG | wxSOCKET\_LOST\_FLAG);
+\end{verbatim}
+In this example, the user will be notified about incoming socket datas and
+a broken connection.
+
+For more information on socket events see \helpref{wxSocket events}{wxsocketbase}.
+
+%
+% SetTimeout
+%
+\membersection{wxSocketBase::SetTimeout}{wxsocketbasesettimeout}
+
+\func{void}{SetTimeout}{\param{int }{seconds}}
+
+This function sets the socket timeout in seconds.
+
+%
+% Notify
+%
+\membersection{wxSocketBase::Notify}\label{wxsocketbasenotify}
+
+\func{void}{Notify}{\param{bool}{ notify}}
+
+Notify will enable (notify is TRUE) or disable (notify is FALSE) the propagation
+of socket events.
+
+% 
+% Ok
+%
+
 \membersection{wxSocketBase::Ok}\label{wxsocketbaseok}
 
 \constfunc{bool}{Ok}{\void}
@@ -88,15 +184,15 @@ Returns TRUE if the socket mustn't wait.
 
 \membersection{wxSocketBase::LastCount}\label{wxsocketbaselastcount}
 
-\constfunc{size\_t}{LastCount}{\void}
+\constfunc{wxUint32}{LastCount}{\void}
 
 Returns the number of bytes read or written by the last IO call.
 
 \membersection{wxSocketBase::LastError}\label{wxsocketbaselasterror}
 
-\constfunc{int}{LastError}{\void}
+\constfunc{wxSocketError}{LastError}{\void}
 
-Returns an error in the errno format (see your C programmer's guide).
+Returns the last occured wxSocket error. See \helpref{wxSocket errors}{wxsocketbase}.
 
 % ---------------------------------------------------------------------------
 % IO calls
@@ -106,7 +202,7 @@ Returns an error in the errno format (see your C programmer's guide).
 %
 \membersection{wxSocketBase::Peek}\label{wxsocketbasepeek}
 
-\func{wxSocketBase\&}{Peek}{\param{char *}{ buffer}, \param{size\_t}{ nbytes}}
+\func{wxSocketBase\&}{Peek}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}}
 
 This function peeks a buffer of {\it nbytes} bytes from the socket. Peeking a buffer
 doesn't delete it from the system socket in-queue.
@@ -132,7 +228,7 @@ Returns a reference to the current object.
 %
 \membersection{wxSocketBase::Read}\label{wxsocketbaseread}
 
-\func{wxSocketBase\&}{Read}{\param{char *}{ buffer}, \param{size\_t}{ nbytes}}
+\func{wxSocketBase\&}{Read}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}}
 
 This function reads a buffer of {\it nbytes} bytes from the socket.
 
@@ -165,25 +261,13 @@ This remark is also valid for all IO call.
 \helpref{wxSocketBase::Error}{wxsocketbaseerror},
  \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount},
  \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}
- 
-\membersection{wxSocketBase::SetFlags}\label{wxsocketbasesetflags}
-
-\func{void}{SetFlags}{\param{wxSockFlags}{ flags}}
-
-\twocolwidtha{7cm}
-\begin{twocollist}\itemsep=0pt
-\twocolitem{{\bf wxSocketBase::NONE}}{Normal functionnalities.}
-\twocolitem{{\bf wxSocketBase::NOWAIT}}{Get the available data in the input queue and exit immediately.}
-\twocolitem{{\bf wxSocketBase::WAITALL}}{Wait for all required data unless an error occured.}
-\twocolitem{{\bf wxSocketBase::SPEED}}{Disable the asynchronous IO functionnality.}
-\end{twocollist}
 
 %
-% Read
+% Write
 %
 \membersection{wxSocketBase::Write}\label{wxsocketbasewrite}
 
-\func{wxSocketBase\&}{Write}{\param{const char *}{ buffer}, \param{size\_t}{ nbytes}}
+\func{wxSocketBase\&}{Write}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}}
 
 This function writes a buffer of {\it nbytes} bytes from the socket.
 
@@ -220,7 +304,7 @@ Returns a reference to the current object.
 %
 \membersection{wxSocketBase::WriteMsg}\label{wxsocketbasewritemsg}
 
-\func{wxSocketBase\&}{WriteMsg}{\param{const char *}{ buffer}, \param{size\_t}{ nbytes}}
+\func{wxSocketBase\&}{WriteMsg}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}}
 
 This function writes a buffer of {\it nbytes} bytes from the socket. But it
 writes a short header before so that ReadMsg can alloc the right size for
@@ -248,7 +332,7 @@ Returns a reference to the current object.
 %
 \membersection{wxSocketBase::ReadMsg}\label{wxsocketbasereadmsg}
 
-\func{wxSocketBase\&}{ReadMsg}{\param{char *}{ buffer}, \param{size\_t}{ nbytes}}
+\func{wxSocketBase\&}{ReadMsg}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}}
 
 This function reads a buffer sent by WriteMsg on a socket. If the buffer passed
 to the function isn't big enough, the function filled it and then discard the
@@ -274,9 +358,9 @@ Returns a reference to the current object.
 %
 % Unread
 %
-\membersection{wxSocketBase::UnRead}\label{wxsocketbaseunread}
+\membersection{wxSocketBase::Unread}\label{wxsocketbaseunread}
 
-\func{wxSocketBase\&}{UnRead}{\param{const char *}{ buffer}, \param{size\_t}{ nbytes}}
+\func{wxSocketBase\&}{Unread}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}}
 
 This function unreads a buffer. It means that the buffer is put in the top
 of the incoming queue. But, it is put also at the end of all unread buffers.
@@ -313,7 +397,7 @@ doesn't wait.
 % ---------------------------------------------------------------------------
 \membersection{wxSocketBase::Wait}\label{wxsocketbasewait}
 
-\func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ microsecond = 0}}
+\func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
 
 This function waits for an event: it could be an incoming byte, the possibility
 for the client to write, a lost connection, an incoming connection, an
@@ -323,7 +407,7 @@ established connection.
 
 \docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.}
 
-\docparam{microsecond}{Number of microseconds to wait.}
+\docparam{millisecond}{Number of milliseconds to wait.}
 
 \wxheading{Return value}
 
@@ -340,7 +424,7 @@ Returns TRUE if an event occured, FALSE if the timeout was reached.
 %
 \membersection{wxSocketBase::WaitForRead}\label{wxsocketbasewaitforread}
 
-\func{bool}{WaitForRead}{\param{long}{ seconds = -1}, \param{long}{ microsecond = 0}}
+\func{bool}{WaitForRead}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
 
 This function waits for a read event.
 
@@ -348,7 +432,7 @@ This function waits for a read event.
 
 \docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.}
 
-\docparam{microsecond}{Number of microseconds to wait.}
+\docparam{millisecond}{Number of milliseconds to wait.}
 
 \wxheading{Return value}
 
@@ -365,7 +449,7 @@ Returns TRUE if a byte arrived, FALSE if the timeout was reached.
 %
 \membersection{wxSocketBase::WaitForWrite}\label{wxsocketbasewaitforwrite}
 
-\func{bool}{WaitForWrite}{\param{long}{ seconds = -1}, \param{long}{ microsecond = 0}}
+\func{bool}{WaitForWrite}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
 
 This function waits for a write event.
 
@@ -373,7 +457,7 @@ This function waits for a write event.
 
 \docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.}
 
-\docparam{microsecond}{Number of microseconds to wait.}
+\docparam{millisecond}{Number of milliseconds to wait.}
 
 \wxheading{Return value}
 
@@ -390,7 +474,7 @@ Returns TRUE if a write event occured, FALSE if the timeout was reached.
 %
 \membersection{wxSocketBase::WaitForLost}\label{wxsocketbasewaitforlost}
 
-\func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ microsecond = 0}}
+\func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
 
 This function waits for a "lost" event. For instance, the peer may have closed
 the connection, or the connection may have been broken.
@@ -399,7 +483,7 @@ the connection, or the connection may have been broken.
 
 \docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.}
 
-\docparam{microsecond}{Number of microseconds to wait.}
+\docparam{millisecond}{Number of milliseconds to wait.}
 
 \wxheading{Return value}
 
@@ -418,7 +502,8 @@ Returns TRUE if a "lost" event occured, FALSE if the timeout was reached.
 
 \func{void}{RestoreState}{\void}
 
-This function restores a previously saved state.
+This function restores the previous state of the socket (include flags,
+notify flags, notify state, C callback function and data).
 
 \wxheading{See also}
 
@@ -441,6 +526,36 @@ actually it saves all flags and the state of the asynchronous callbacks.
 
 \helpref{wxSocketBase::RestoreState}{wxsocketbaserestorestate}
 
+%
+% GetLocal
+%
+\membersection{wxSocketBase::GetLocal}{wxsocketbasegetlocal}
+
+\constfunc{bool}{GetLocal}{\param{wxSockAddress\& }{addr_man}}
+
+This function returns the local address field of the socket. The local
+address field contains the complete local address of the socket (local
+address, local port, ...).
+
+\wxheading{Return value}
+
+It returns TRUE if no errors happened, FALSE otherwise.
+
+%
+% GetPeer
+%
+\membersection{wxSocketBase::GetPeer}{wxsocketbasegetlocal}
+
+\constfunc{bool}{GetPeer}{\param{wxSockAddress\& }{addr_man}}
+
+This function returns the peer address field of the socket. The peer 
+address field contains the complete peer host address of the socket
+(address, port, ...).
+
+\wxheading{Return value}
+
+It returns TRUE if no errors happened, FALSE otherwise.
+
 % ---------------------------------------------------------------------------
 % Socket callbacks
 % ---------------------------------------------------------------------------
@@ -458,7 +573,43 @@ Sets an event handler to be called when a socket event occured.
 
 \wxheading{See also}
 
+\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}
+\helpref{wxSocketBase::Notify}{wxsocketbasenotify}
 \helpref{wxSocketEvent}{wxsocketevent}
+\helpref{wxEvtHandler}{wxevthandler}
+
+\membersection{wxSocketBase::Callback}\label{wxsocketbasecallback}
+
+\func{wxSocketBase::wxSockCbk}{Callback}{\param{wxSocketBase::wxSockCbk}{ callback}}
+
+wxSocket event handler can call C callback. This function allows you to set it.
+The format of the callback is as followed:
+\begin{verbatim}
+void SocketCallback(wxSocketBase& sock,wxSocketNotify evt,char *cdata);
+\end{verbatim}
+
+The first parameter reminds you of the caller socket. The second parameter
+informs you about the current event (See \helpref{wxSocket events}{wxsocketbase}).
+The third parameters is the client data you specified using \helpref{CallbackData}{wxsocketcallbackdata}.
+
+\wxheading{Return value}
+
+It returns the previous callback.
+
+\wxheading{See also}
+
+\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}
+\helpref{wxSocketBase::Notify}{wxsocketbasenotify}
+
+\membersection{wxSocketBase::CallbackData}\label{wxsocketcallbackdata}
+
+\func{char *}{CallbackData}{\param{char *}{cdata}}
+
+This function sets the the client data which will be passed to a \helpref{C callback}{wxsocketbasecallback}.
+
+\wxheading{Return value}
+
+This function returns the old value of the client data pointer.
 
 % ---------------------------------------------------------------------------
 % CLASS wxSocketClient
@@ -469,6 +620,10 @@ Sets an event handler to be called when a socket event occured.
 
 \helpref{wxSocketBase}{wxsocketbase}
 
+\wxheading{Include files}
+
+<wx/socket.h>
+
 % ---------------------------------------------------------------------------
 % Members
 % ---------------------------------------------------------------------------
@@ -481,8 +636,6 @@ Sets an event handler to be called when a socket event occured.
 
 Constructs a new wxSocketClient.
 
-{\bf Warning !} The new socket client needs to be registered to a socket handler (See \helpref{wxSocketHandler}{wxsockethandler}).
-
 \wxheading{Parameters}
 
 \docparam{flags}{Socket flags (See \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags})}
@@ -525,7 +678,7 @@ Returns TRUE if the connection is established and no error occurs.
 %
 \membersection{wxSocketClient::WaitOnConnect}\label{wxsocketclientwaitonconnect}
 
-\func{bool}{WaitOnConnect}{\param{long}{ seconds = -1}, \param{long}{ microseconds = 0}}
+\func{bool}{WaitOnConnect}{\param{long}{ seconds = -1}, \param{long}{ milliseconds = 0}}
 
 Wait for a "connect" event.
 
@@ -544,6 +697,10 @@ This event class contains information about socket events.
 
 \helpref{wxEvent}{wxevent}
 
+\wxheading{Include files}
+
+<wx/socket.h>
+
 \wxheading{Event table macros}
 
 To process a socket event, use these event handler macros to direct input to member
@@ -556,7 +713,6 @@ functions that take a wxSocketEvent argument.
 
 \wxheading{See also}
 
-\helpref{wxSocketHandler}{wxsockethandler},\rtfsp
 \helpref{wxSocketBase}{wxsocketbase},\rtfsp
 \helpref{wxSocketClient}{wxsocketclient},\rtfsp
 \helpref{wxSocketServer}{wxsocketserver}
@@ -571,159 +727,10 @@ Constructor.
 
 \membersection{wxSocketEvent::SocketEvent}\label{wxsocketeventsocketevent}
 
-\constfunc{wxSocketBase::wxRequestEvent}{SocketEvent}{\void}
+\constfunc{wxSocketNotify}{SocketEvent}{\void}
 
 Returns the socket event type.
 
-% ---------------------------------------------------------------------------
-% CLASS: wxSocketHandler
-% ---------------------------------------------------------------------------
-\section{\class{wxSocketHandler}}\label{wxsockethandler}
-
-\wxheading{Derived from}
-
-\helpref{wxObject}{wxobject}
-
-% ---------------------------------------------------------------------------
-% Members
-% ---------------------------------------------------------------------------
-\latexignore{\rtfignore{\wxheading{Members}}}
-
-%
-% wxSocketHandler
-%
-\membersection{wxSocketHandler::wxSocketHandler}
-
-\func{}{wxSocketHandler}{\void}
-
-Constructs a new wxSocketHandler.
-
-It is advised to use \helpref{wxSocketHandler::Master}{wxsockethandlermaster} to
-get a socket handler. But creating a socket handler is useful to group
-many sockets.
-
-%
-% ~wxSocketHandler
-%
-\membersection{wxSocketHandler::\destruct{wxSocketHandler}}
-
-\func{}{\destruct{wxSocketHandler}}{\void}
-
-Destroys a wxSocketHandler object.
-
-%
-% Register
-%
-\membersection{wxSocketHandler::Register}
-
-\func{void}{Register}{\param{wxSocketBase *}{socket}}
-
-Register a socket: if it is already registered in this handler it will just
-return immediately.
-
-\wxheading{Parameters}
-
-\docparam{socket}{Socket to be registered.}
-
-%
-% UnRegister
-%
-\membersection{wxSocketHandler::UnRegister}
-
-\func{void}{UnRegister}{\param{wxSocketBase *}{socket}}
-
-UnRegister a socket: if it isn't registered in this handler it will just
-return.
-
-\wxheading{Parameters}
-
-\docparam{socket}{Socket to be unregistered.}
-
-%
-% Count
-%
-\membersection{wxSocketHandler::Count}
-
-\constfunc{unsigned long}{Count}{\void}
-
-Returns the number of sockets registered in the handler.
-
-\wxheading{Return value}
-
-Number of sockets registered.
-
-%
-% CreateServer
-%
-\membersection{wxSocketHandler::CreateServer}
-
-\func{wxSocketServer *}{CreateServer}{\param{wxSockAddress\&}{ address}, \param{wxSocketBase::wxSockFlags}{ flags = wxSocketbase::NONE}}
-
-Creates a new wxSocketServer object. The object is automatically registered
-to the current socket handler.
-For a detailed description of the parameters, see \helpref{wxSocketServer::wxSocketServer}{wxsocketserverconstr}.
-
-\wxheading{Return value}
-
-Returns a new socket server.
-
-%
-% CreateClient
-%
-\membersection{wxSocketHandler::CreateClient}
-
-\func{wxSocketServer *}{CreateClient}{\param{wxSocketBase::wxSockFlags}{ flags = wxSocketbase::NONE}}
-
-Creates a new wxSocketClient object. The object is automatically registered
-to the current socket handler.
-
-For a detailed description of the parameters, see \helpref{wxSocketClient::Connect}{wxsocketclientconnect}.
-
-\wxheading{Return value}
-
-Returns a new socket client.
-
-%
-% Master
-%
-\membersection{wxSocketHandler::Master}\label{wxsockethandlermaster}
-
-\func{static wxSocketHandler\&}{Master}{\void}
-
-Returns a default socket handler.
-
-%
-% Wait
-%
-\membersection{wxSocketHandler::Wait}
-
-\func{int}{Wait}{\param{long}{ seconds},\param{long}{ microseconds}}
-
-Wait for an event on all registered sockets.
-
-\wxheading{Parameters}
-
-\docparam{seconds}{Number of seconds to wait. By default, it waits infinitely.}
-
-\docparam{microsecond}{Number of microseconds to wait.}
-
-\wxheading{Return value}
-
-Returns 0 if a timeout occured, else the number of events detected.
-
-\wxheading{See also}
-
-\helpref{wxSocketBase::Wait}{wxsocketbasewait}
-
-%
-% YieldSock
-%
-\membersection{wxSocketHandler::YieldSock}
-
-\func{void}{YieldSock}{\void}
-
-Execute pending requests in all registered sockets.
-
 % ---------------------------------------------------------------------------
 % CLASS: wxSocketServer
 % ---------------------------------------------------------------------------
@@ -733,6 +740,10 @@ Execute pending requests in all registered sockets.
 
 \helpref{wxSocketBase}{wxsocketbase}
 
+\wxheading{Include files}
+
+<wx/socket.h>
+
 % ---------------------------------------------------------------------------
 % Members
 % ---------------------------------------------------------------------------
@@ -747,9 +758,6 @@ Execute pending requests in all registered sockets.
 
 Constructs a new wxSocketServer.
 
-{\bf Warning !} The created object needs to be registered to a socket handler
-(see \helpref{wxSocketHandler}{wxsockethandler}).
-
 \wxheading{Parameters}
 
 \docparam{address}{Specifies the local address for the server (e.g. port number).}
