]> git.saurik.com Git - wxWidgets.git/blobdiff - docs/latex/wx/socket.tex
Updated to reflect some of the latest changes
[wxWidgets.git] / docs / latex / wx / socket.tex
index eae9022e3cba49b9dbd986c47e9a904ad0c2a921..a8a067dc0668f672635d077e01eaf7e5b675e48d 100644 (file)
@@ -11,6 +11,9 @@
 
 \section{\class{wxSocketBase}}\label{wxsocketbase}
 
+wxSocketBase is the base class for all socket-related objects, and it
+defines all basic IO functionality.
+
 \wxheading{Derived from}
 
 \helpref{wxEvtHandler}{wxevthandler}
@@ -77,12 +80,13 @@ a delayed connection request fails.
 
 \wxheading{Event handling}
 
-To process events from a socket, use the following event handler macro to direct
-input to member functions that take a \helpref{wxSocketEvent}{wxsocketevent} argument.
+To process events coming from a socket object, use the following event
+handler macro to direct events to member functions that take a
+\helpref{wxSocketEvent}{wxsocketevent} argument.
 
 \twocolwidtha{7cm}%
 \begin{twocollist}\itemsep=0pt
-\twocolitem{{\bf EVT\_SOCKET(id, func)}}{A socket event occured.}
+\twocolitem{{\bf EVT\_SOCKET(id, func)}}{Process a wxEVT\_SOCKET event.}
 \end{twocollist}
 
 \wxheading{See also}
@@ -93,35 +97,420 @@ input to member functions that take a \helpref{wxSocketEvent}{wxsocketevent} arg
 \helpref{Sockets sample}{samplesockets}
 
 % ---------------------------------------------------------------------------
-% Members
+% Function groups
 % ---------------------------------------------------------------------------
 
-\latexignore{\rtfignore{\wxheading{Members}}}
+\latexignore{\rtfignore{\wxheading{Function groups}}}
 
-\membersection{wxSocketBase::wxSocketBase}
+\membersection{Construction and destruction}
 
-\func{}{wxSocketBase}{\void}
+\helpref{wxSocketBase}{wxsocketbaseconstruct}\\
+\helpref{\destruct{wxSocketBase}}{wxsocketbasedestruct}\\
+\helpref{wxDestroy}{wxsocketbasedestroy}
 
-Default constructor. Don't use it; use \helpref{wxSocketClient}{wxsocketclient} 
-or \helpref{wxSocketServer}{wxsocketserver}.
+\membersection{Socket state}
 
-\membersection{wxSocketBase::\destruct{wxSocketBase}}
+Functions to retrieve current state and miscellaneous info.
 
-\func{}{\destruct{wxSocketBase}}{\void}
+\helpref{Error}{wxsocketbaseerror}\\
+\helpref{GetLocal}{wxsocketbasegetlocal}\\
+\helpref{GetPeer}{wxsocketbasegetpeer}
+\helpref{IsConnected}{wxsocketbaseisconnected}\\
+\helpref{IsData}{wxsocketbaseisdata}\\
+\helpref{IsDisconnected}{wxsocketbaseisdisconnected}\\
+\helpref{LastCount}{wxsocketbaselastcount}\\
+\helpref{LastError}{wxsocketbaselasterror}\\
+\helpref{Ok}{wxsocketbaseok}\\
+\helpref{SaveState}{wxsocketbasesavestate}\\
+\helpref{RestoreState}{wxsocketbaserestorestate}
+
+\membersection{Basic IO}
+
+Functions that perform basic IO functionality.
+
+\helpref{Close}{wxsocketbaseclose}\\
+\helpref{Discard}{wxsocketbasediscard}\\
+\helpref{Peek}{wxsocketbasepeek}\\
+\helpref{Read}{wxsocketbaseread}\\
+\helpref{ReadMsg}{wxsocketbasereadmsg}\\
+\helpref{Unread}{wxsocketbaseunread}\\
+\helpref{Write}{wxsocketbasewrite}\\
+\helpref{WriteMsg}{wxsocketbasewritemsg}
+
+Functions that perform a timed wait on a certain IO condition.
+
+\helpref{Wait}{wxsocketbasewait}\\
+\helpref{WaitForRead}{wxsocketbasewaitforread}\\
+\helpref{WaitForWrite}{wxsocketbasewaitforwrite}\\
+\helpref{WaitForLost}{wxsocketbasewaitforlost}
+
+Functions that allow applications to customize socket IO as needed.
+
+\helpref{SetFlags}{wxsocketbasesetflags}\\
+\helpref{SetTimeout}{wxsocketbasesettimeout}
+
+\membersection{Handling socket events}
+
+Functions that allow applications to receive socket events.
+
+\helpref{Notify}{wxsocketbasenotify}\\
+\helpref{SetNotify}{wxsocketbasesetnotify}\\
+\helpref{SetEventHandler}{wxsocketbaseseteventhandler}
+
+Callback functions are also available, but they are provided for backwards
+compatibility only. Their use is discouraged in favour of events, and should
+be considered deprecated.
+
+\helpref{Callback}{wxsocketbasecallback}\\
+\helpref{CallbackData}{wxsocketbasecallbackdata}
 
-Destructor.
 
 % ---------------------------------------------------------------------------
-% State functions
+% Members here
 % ---------------------------------------------------------------------------
 
+\helponly{\insertatlevel{2}{
+
+\wxheading{Members}
+
+}}
+
+\membersection{wxSocketBase::wxSocketBase}\label{wxsocketbaseconstruct}
+
+\func{}{wxSocketBase}{\void}
+
+Default constructor. Don't use it directly; instead, use
+\helpref{wxSocketClient}{wxsocketclient} to construct a socket client, or
+\helpref{wxSocketServer}{wxsocketserver} to construct a socket server.
+
+\membersection{wxSocketBase::\destruct{wxSocketBase}}\label{wxsocketbasedestruct}
+
+\func{}{\destruct{wxSocketBase}}{\void}
+
+Destructor. Do not destroy a socket using the delete operator directly;
+use \helpref{Destroy}{wxsocketbasedestroy} instead. Also, do not create socket
+objects in the stack.
+
 %
-% SetFlags
+% Callback
+%
+\membersection{wxSocketBase::Callback}\label{wxsocketbasecallback}
+
+\func{wxSocketBase::wxSockCbk}{Callback}{\param{wxSocketBase::wxSockCbk}{ callback}}
+
+You can setup a callback function to be called when an event occurs.
+The function will be called only for those events for which notification
+has been enabled with \helpref{Notify}{wxsocketbasenotify} and
+\helpref{SetNotify}{wxsocketbasesetnotify}. The prototype of the
+callback must be as follows:
+
+\begin{verbatim}
+void SocketCallback(wxSocketBase& sock, wxSocketNotify evt, char *cdata);
+\end{verbatim}
+
+The first parameter is a reference to the socket object in which the
+event occured. The second parameter tells you which event occured.
+(See \helpref{wxSocket events}{wxsocketbase}). The third parameter
+is the user data you specified using
+\helpref{CallbackData}{wxsocketbasecallbackdata}.
+
+Note that events are preferred over callbacks where possible.
+
+\wxheading{Return value}
+
+A pointer to the previous callback.
+
+\wxheading{See also}
+
+\helpref{wxSocketBase::CallbackData}{wxsocketbasecallbackdata}, 
+\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, 
+\helpref{wxSocketBase::Notify}{wxsocketbasenotify}
+
+%
+% CallbackData
+%
+\membersection{wxSocketBase::CallbackData}\label{wxsocketbasecallbackdata}
+
+\func{char *}{CallbackData}{\param{char *}{cdata}}
+
+This function sets the the user data which will be passed to a
+callback function set via \helpref{Callback}{wxsocketbasecallback}.
+
+Note that events are preferred over callbacks where possible.
+
+\wxheading{Return value}
+
+A pointer to the previous user data.
+
+\helpref{wxSocketBase::Callback}{wxsocketbasecallback}, 
+\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, 
+\helpref{wxSocketBase::Notify}{wxsocketbasenotify}
+
+%
+% Close
+%
+\membersection{wxSocketBase::Close}\label{wxsocketbaseclose}
+
+\func{void}{Close}{\void}
+
+This function shuts down the socket, disabling further transmission and
+reception of data; it also disables events for the socket and frees the
+associated system resources. Upon socket destruction, Close is automatically
+called. This means that you don't need to do it yourself, unless you
+explicitly want to disable further operation.
+
+\wxheading{Remark/Warning}
+
+Although Close immediately disables events for the socket, it is possible
+that event messages may be waiting in the application's event queue. The
+application must therefore be prepared to handle socket event messages
+even after calling Close.
+
+%
+% Destroy
+%
+\membersection{wxSocketBase::Destroy}\label{wxsocketbasedestroy}
+
+\func{bool}{Destroy}{\void}
+
+Destroys the socket safely. Use this function instead of the delete operator,
+since otherwise socket events could reach the application even after the
+socket has been destroyed. To prevent this problem, this function appends
+the wxSocket to a list of object to be deleted on idle time, after all
+events have been processed. For the same reason, you should avoid creating
+socket objects in the stack.
+
+Destroy calls \helpref{Close}{wxsocketbaseclose} automatically.
+
+\wxheading{Return value}
+
+Always TRUE.
+
+%
+% Discard
+%
+\membersection{wxSocketBase::Discard}\label{wxsocketbasediscard}
+
+\func{wxSocketBase\&}{Discard}{\void}
+
+This function simply deletes all bytes in the incoming queue. This function
+always returns immediately and its operation is not affected by IO flags.
+
+Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually discarded.
+
+If you use \helpref{Error}{wxsocketbaseerror}, it will always return FALSE.
+
+%
+% Error
+%
+\membersection{wxSocketBase::Error}\label{wxsocketbaseerror}
+
+\constfunc{bool}{Error}{\void}
+
+Returns TRUE if an error occured in the last IO operation.
+
+Use this function to check for an error condition after one of the
+following calls: Discard, Peek, Read, ReadMsg, Unread, Write, WriteMsg.
+
+%
+% GetLocal
+%
+\membersection{wxSocketBase::GetLocal}\label{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}\label{wxsocketbasegetpeer}
+
+\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.
+
+%
+% IsConnected
+%
+\membersection{wxSocketBase::IsConnected}\label{wxsocketbaseisconnected}
+
+\constfunc{bool}{IsConnected}{\void}
+
+Returns TRUE if the socket is connected.
+
+%
+% IsData
+%
+\membersection{wxSocketBase::IsData}\label{wxsocketbaseisdata}
+
+\constfunc{bool}{IsData}{\void}
+
+This function waits until the socket is readable. This might mean that
+queued data is available for reading or, for streamed sockets, that
+the connection has been closed, so that a read operation will complete
+immediately without blocking (unless the {\bf wxSOCKET\_WAITALL} flag
+is set, in which case the operation might still block).
+
+\membersection{wxSocketBase::IsDisconnected}\label{wxsocketbaseisdisconnected}
+
+%
+% IsDisconnected
+%
+\constfunc{bool}{IsDisconnected}{\void}
+
+Returns TRUE if the socket is not connected.
+
+\membersection{wxSocketBase::LastCount}\label{wxsocketbaselastcount}
+
+%
+% LastCount
+%
+\constfunc{wxUint32}{LastCount}{\void}
+
+Returns the number of bytes read or written by the last IO call.
+
+Use this function to get the number of bytes actually transferred
+after using one of the following IO calls: Discard, Peek, Read,
+ReadMsg, Unread, Write, WriteMsg.
+
+%
+% LastError
+%
+\membersection{wxSocketBase::LastError}\label{wxsocketbaselasterror}
+
+\constfunc{wxSocketError}{LastError}{\void}
+
+Returns the last wxSocket error. See \helpref{wxSocket errors}{wxsocketbase}.
+
+Please note that this function merely returns the last error code,
+but it should not be used to determine if an error has occured (this
+is because successful operations do not change the LastError value).
+Use \helpref{Error}{wxsocketbaseerror} first, in order to determine
+if the last IO call failed. If this returns TRUE, use LastError
+to discover the cause of the error.
+
+%
+% Notify
+%
+\membersection{wxSocketBase::Notify}\label{wxsocketbasenotify}
+
+\func{void}{Notify}{\param{bool}{ notify}}
+
+According to the {\it notify} value, this function enables
+or disables socket events. If {\it notify} is TRUE, the events
+configured with \helpref{SetNotify}{wxsocketbasesetnotify} will
+be sent to the application. If {\it notify} is FALSE; no events
+will be sent.
+
+% 
+% Ok
+%
+\membersection{wxSocketBase::Ok}\label{wxsocketbaseok}
+
+\constfunc{bool}{Ok}{\void}
+
+Returns TRUE if the socket is initialized and ready and FALSE in other
+cases.
+
+\wxheading{Remark/Warning}
+
+For \helpref{wxSocketClient}{wxsocketclient}, Ok won't return TRUE unless
+the client is connected to a server.
+
+For \helpref{wxSocketServer}{wxsocketserver}, Ok will return TRUE if the
+server could bind to the specified address and is already listening for
+new connections.
+
+Ok does not check for IO errors; use \helpref{Error}{wxsocketbaseerror}
+instead for that purpose.
+
 %
+% RestoreState
+%
+\membersection{wxSocketBase::RestoreState}\label{wxsocketbaserestorestate}
+
+\func{void}{RestoreState}{\void}
+
+This function restores the previous state of the socket, as saved
+with \helpref{SaveState}{wxsocketbasesavestate}
+
+Calls to SaveState and RestoreState can be nested.
+
+\wxheading{See also}
+
+\helpref{wxSocketBase::SaveState}{wxsocketbasesavestate}
+
+%
+% SaveState
+%
+\membersection{wxSocketBase::SaveState}\label{wxsocketbasesavestate}
+
+\func{void}{SaveState}{\void}
+
+This function saves the current state of the socket in a stack. Socket
+state includes flags, as set with \helpref{SetFlags}{wxsocketbasesetflags},
+event mask, as set with \helpref{SetNotify}{wxsocketbasesetnotify} and
+\helpref{Notify}{wxsocketbasenotify}, and current settings for the
+asynchronous callbacks, as set with \helpref{Callback}{wxsocketbasecallback}
+and \helpref{CallbackData}{wxsocketbasecallbackdata}.
+
+Calls to SaveState and RestoreState can be nested.
+
+\wxheading{See also}
+
+\helpref{wxSocketBase::RestoreState}{wxsocketbaserestorestate}
+
+%
+% SetEventHandler
+%
+\membersection{wxSocketBase::SetEventHandler}\label{wxsocketbaseseteventhandler}
+
+\func{void}{SetEventHandler}{\param{wxEvtHandler\&}{ evt\_hdlr}, \param{int}{ id = -1}}
+
+Sets an event handler to be called when a socket event occurs. The
+handler will be called for those events for which notification is
+enabled with \helpref{SetNotify}{wxsocketbasesetnotify} and
+\helpref{Notify}{wxsocketbasenotify}.
 
+You can also specify a callback function to be called when an event
+occurs, although if possible, events should be used instead of callbacks.
+See \helpref{Callback}{wxsocketbasecallback} and
+\helpref{CallbackData}{wxsocketbasecallbackdata}.
+
+\wxheading{Parameters}
+
+\docparam{evt\_hdlr}{Specifies the event handler you want to use.}
+
+\docparam{id}{The id of socket event.}
+
+\wxheading{See also}
+
+\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, 
+\helpref{wxSocketBase::Notify}{wxsocketbasenotify}, 
+\helpref{wxSocketEvent}{wxsocketevent}, 
+\helpref{wxEvtHandler}{wxevthandler}, 
+\helpref{wxSocketBase::Callback}{wxsocketbasecallback}, 
+\helpref{wxSocketBase::CallbackData}{wxsocketbasecallbackdata}
+
+%
+% SetFlags
+%
 \membersection{wxSocketBase::SetFlags}\label{wxsocketbasesetflags}
 
-\func{void}{SetFlags}{\param{wxSocketBase::wxSockFlags}{ flags}}
+\func{void}{SetFlags}{\param{wxSocketBase::wxSocketFlags}{ flags}}
 
 \twocolwidtha{7cm}
 \begin{twocollist}\itemsep=0pt
@@ -213,94 +602,17 @@ For more information on socket events see \helpref{wxSocket events}{wxsocketbase
 
 \func{void}{SetTimeout}{\param{int }{seconds}}
 
-This function sets the default socket timeout in seconds. This timeout
-applies to all IO calls, and also to the \helpref{Wait}{wxsocketbasewait}
-family of functions if you don't specify a wait interval. Initially, the
-default is set to 10 minutes.
-
-%
-% Notify
-%
-\membersection{wxSocketBase::Notify}\label{wxsocketbasenotify}
-
-\func{void}{Notify}{\param{bool}{ notify}}
-
-According to the {\it notify} value, this function enables
-or disables socket events. If {\it notify} is TRUE, the events
-configured with \helpref{SetNotify}{wxsocketbasesetnotify} will
-be sent to the application. If {\it notify} is FALSE; no events
-will be sent.
-
-% 
-% Ok
-%
-
-\membersection{wxSocketBase::Ok}\label{wxsocketbaseok}
-
-\constfunc{bool}{Ok}{\void}
-
-Returns TRUE if the socket is initialized and ready and FALSE in other
-cases.
-
-\membersection{wxSocketBase::Error}\label{wxsocketbaseerror}
-
-\constfunc{bool}{Error}{\void}
-
-Returns TRUE if an error occured in the last IO operation.
-
-Use this function to check for an error condition after one of the
-following calls: Read, Write, ReadMsg, WriteMsg, Peek, Unread, Discard.
-
-\membersection{wxSocketBase::IsConnected}\label{wxsocketbaseisconnected}
-
-\constfunc{bool}{IsConnected}{\void}
-
-Returns TRUE if the socket is connected.
-
-\membersection{wxSocketBase::IsData}\label{wxsocketbaseisdata}
-
-\constfunc{bool}{IsData}{\void}
-
-Returns TRUE if there is data available to be read. 
-
-\membersection{wxSocketBase::IsDisconnected}\label{wxsocketbasedisconnected}
-
-\constfunc{bool}{IsDisconnected}{\void}
-
-Returns TRUE if the socket is not connected.
-
-\membersection{wxSocketBase::LastCount}\label{wxsocketbaselastcount}
-
-\constfunc{wxUint32}{LastCount}{\void}
-
-Returns the number of bytes read or written by the last IO call.
-
-Use this function to get the number of bytes actually transferred
-after using one of the following IO calls: Read, Write, ReadMsg,
-WriteMsg, Peek, Unread, Discard.
-
-\membersection{wxSocketBase::LastError}\label{wxsocketbaselasterror}
-
-\constfunc{wxSocketError}{LastError}{\void}
-
-Returns the last wxSocket error. See \helpref{wxSocket errors}{wxsocketbase}.
-
-Please note that this function merely returns the last error code,
-but it should not be used to determine if an error has occured (this
-is because successful operations do not change the LastError value).
-Use \helpref{Error}{wxsocketbaseerror} first, in order to determine
-if the last IO call failed. If this returns TRUE, use LastError()
-to discover the cause of the error.
+This function sets the default socket timeout in seconds. This timeout
+applies to all IO calls, and also to the \helpref{Wait}{wxsocketbasewait}
+family of functions if you don't specify a wait interval. Initially, the
+default is set to 10 minutes.
 
-% ---------------------------------------------------------------------------
-% IO calls
-% ---------------------------------------------------------------------------
 %
 % Peek
 %
 \membersection{wxSocketBase::Peek}\label{wxsocketbasepeek}
 
-\func{wxSocketBase\&}{Peek}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}}
+\func{wxSocketBase\&}{Peek}{\param{void *}{ 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 socket input queue.
@@ -321,7 +633,7 @@ Returns a reference to the current object.
 
 \wxheading{Remark/Warning}
 
-The exact behaviour of wxSocketBase::Peek() depends on the combination
+The exact behaviour of wxSocketBase::Peek depends on the combination
 of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}
 
 \wxheading{See also}
@@ -336,7 +648,7 @@ of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetF
 %
 \membersection{wxSocketBase::Read}\label{wxsocketbaseread}
 
-\func{wxSocketBase\&}{Read}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}}
+\func{wxSocketBase\&}{Read}{\param{void *}{ buffer}, \param{wxUint32}{ nbytes}}
 
 This function reads a buffer of {\it nbytes} bytes from the socket.
 
@@ -356,42 +668,7 @@ Returns a reference to the current object.
 
 \wxheading{Remark/Warning}
 
-The exact behaviour of wxSocketBase::Read() depends on the combination
-of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
-
-\wxheading{See also}
-
-\helpref{wxSocketBase::Error}{wxsocketbaseerror}, 
-\helpref{wxSocketBase::LastError}{wxsocketbaselasterror}, 
-\helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, 
-\helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}
-
-%
-% Write
-%
-\membersection{wxSocketBase::Write}\label{wxsocketbasewrite}
-
-\func{wxSocketBase\&}{Write}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}}
-
-This function writes a buffer of {\it nbytes} bytes to the socket.
-
-Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually written.
-
-Use \helpref{Error}{wxsocketbaseerror} to determine if the operation succeeded.
-
-\wxheading{Parameters}
-
-\docparam{buffer}{Buffer with the data to be sent.}
-
-\docparam{nbytes}{Number of bytes.}
-
-\wxheading{Return value}
-
-Returns a reference to the current object.
-
-\wxheading{Remark/Warning}
-
-The exact behaviour of wxSocketBase::Write() depends on the combination
+The exact behaviour of wxSocketBase::Read depends on the combination
 of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
 
 \wxheading{See also}
@@ -401,54 +678,12 @@ of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetF
 \helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, 
 \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}
 
-%
-% WriteMsg
-%
-\membersection{wxSocketBase::WriteMsg}\label{wxsocketbasewritemsg}
-
-\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 \helpref{ReadMsg}{wxsocketbasereadmsg}
-knows how much data should it actually read. So, a buffer sent with WriteMsg
-{\bf must} be read with ReadMsg. This function always waits for the entire
-buffer to be sent, unless an error occurs.
-
-Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually written.
-
-Use \helpref{Error}{wxsocketbaseerror} to determine if the operation succeeded.
-
-\wxheading{Parameters}
-
-\docparam{buffer}{Buffer with the data to be sent.}
-
-\docparam{nbytes}{Number of bytes to send.}
-
-\wxheading{Return value}
-
-Returns a reference to the current object.
-
-\wxheading{Remark/Warning}
-
-wxSocketBase::WriteMsg() will behave as if the {\bf wxSOCKET\_WAITALL} flag
-was always set and it will always ignore the {\bf wxSOCKET\_NOWAIT} flag.
-The exact behaviour of WriteMsg depends on the {\bf wxSOCKET\_BLOCK} flag.
-For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
-
-\wxheading{See also}
-
-\helpref{wxSocketBase::Error}{wxsocketbaseerror}, 
-\helpref{wxSocketBase::LastError}{wxsocketbaselasterror}, 
-\helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, 
-\helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}, 
-\helpref{wxSocketBase::ReadMsg}{wxsocketbasereadmsg}
-
 %
 % ReadMsg
 %
 \membersection{wxSocketBase::ReadMsg}\label{wxsocketbasereadmsg}
 
-\func{wxSocketBase\&}{ReadMsg}{\param{char *}{ buffer}, \param{wxUint32}{ nbytes}}
+\func{wxSocketBase\&}{ReadMsg}{\param{void *}{ buffer}, \param{wxUint32}{ nbytes}}
 
 This function reads a buffer sent by \helpref{WriteMsg}{wxsocketbasewritemsg}
 on a socket. If the buffer passed to the function isn't big enough, the
@@ -471,7 +706,7 @@ Returns a reference to the current object.
 
 \wxheading{Remark/Warning}
 
-wxSocketBase::ReadMsg() will behave as if the {\bf wxSOCKET\_WAITALL} flag
+wxSocketBase::ReadMsg will behave as if the {\bf wxSOCKET\_WAITALL} flag
 was always set and it will always ignore the {\bf wxSOCKET\_NOWAIT} flag.
 The exact behaviour of ReadMsg depends on the {\bf wxSOCKET\_BLOCK} flag.
 For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
@@ -489,7 +724,7 @@ For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbaseset
 %
 \membersection{wxSocketBase::Unread}\label{wxsocketbaseunread}
 
-\func{wxSocketBase\&}{Unread}{\param{const char *}{ buffer}, \param{wxUint32}{ nbytes}}
+\func{wxSocketBase\&}{Unread}{\param{const void *}{ buffer}, \param{wxUint32}{ nbytes}}
 
 This function unreads a buffer. That is, the data in the buffer is put back
 in the incoming queue. This function is not affected by wxSocket flags.
@@ -515,22 +750,8 @@ Returns a reference to the current object.
 \helpref{wxSocketBase::LastError}{wxsocketbaselasterror}
 
 %
-% Discard
+% Wait
 %
-\membersection{wxSocketBase::Discard}\label{wxsocketbasediscard}
-
-\func{wxSocketBase\&}{Discard}{\void}
-
-This function simply deletes all bytes in the incoming queue. This function
-always returns immediately and its operation is not affected by IO flags.
-
-Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually discarded.
-
-If you use \helpref{Error}{wxsocketbaseerror}, it will always return FALSE.
-
-% ---------------------------------------------------------------------------
-% Wait functions
-% ---------------------------------------------------------------------------
 \membersection{wxSocketBase::Wait}\label{wxsocketbasewait}
 
 \func{bool}{Wait}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
@@ -540,7 +761,7 @@ that it is recommended to use the individual Wait functions to wait for
 the required condition, instead of this one.
                                             
 \begin{itemize}
-\item There is data available for reading.
+\item The socket becomes readable.
 \item The socket becomes writable.
 \item An ongoing connection request has completed (only for clients)
 \item An incoming connection request has arrived (only for servers)
@@ -573,8 +794,11 @@ FALSE if the timeout was reached.
 
 \func{bool}{WaitForRead}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
 
-This function waits until there is data available to be read, or until
-an error occurs.
+This function waits until the socket is readable. This might mean that
+queued data is available for reading or, for streamed sockets, that
+the connection has been closed, so that a read operation will complete
+immediately without blocking (unless the {\bf wxSOCKET\_WAITALL} flag
+is set, in which case the operation might still block).
 
 \wxheading{Parameters}
 
@@ -586,8 +810,7 @@ as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
 
 \wxheading{Return value}
 
-Returns TRUE if there is data to be read, FALSE if the timeout was reached
-or an error occured.
+Returns TRUE if the socket becomes readable, FALSE on timeout.
 
 \wxheading{See also}
 
@@ -602,8 +825,11 @@ or an error occured.
 
 \func{bool}{WaitForWrite}{\param{long}{ seconds = -1}, \param{long}{ millisecond = 0}}
 
-This function waits until the socket is ready to send data,
-or until an error occurs.
+This function waits until the socket becomes writable. This might mean that
+the socket is ready to send new data, or for streamed sockets, that the
+connection has been closed, so that a write operation is guaranteed to
+complete immediately (unless the {\bf wxSOCKET\_WAITALL} flag is set,
+in which case the operation might still block).
 
 \wxheading{Parameters}
 
@@ -615,8 +841,7 @@ as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
 
 \wxheading{Return value}
 
-Returns TRUE if you can write to the socket, FALSE if the timeout was
-reached or an error occured.
+Returns TRUE if the socket becomes writable, FALSE on timeout.
 
 \wxheading{See also}
 
@@ -652,160 +877,88 @@ Returns TRUE if the connection was lost, FALSE if the timeout was reached.
 \helpref{wxSocketBase::WaitForWrite}{wxsocketbasewaitforwrite}, 
 \helpref{wxSocketBase::WaitForLost}{wxsocketbasewaitforlost}
 
-% ---------------------------------------------------------------------------
-% Socket state
-% ---------------------------------------------------------------------------
-
 %
-% RestoreState
+% Write
 %
-\membersection{wxSocketBase::RestoreState}\label{wxsocketbaserestorestate}
-
-\func{void}{RestoreState}{\void}
-
-This function restores the previous state of the socket, as saved
-with \helpref{SaveState}{wxsocketbasesavestate}
-
-Calls to SaveState and RestoreState can be nested.
+\membersection{wxSocketBase::Write}\label{wxsocketbasewrite}
 
-\wxheading{See also}
+\func{wxSocketBase\&}{Write}{\param{const void *}{ buffer}, \param{wxUint32}{ nbytes}}
 
-\helpref{wxSocketBase::SaveState}{wxsocketbasesavestate}
+This function writes a buffer of {\it nbytes} bytes to the socket.
 
-%
-% SaveState
-%
-\membersection{wxSocketBase::SaveState}\label{wxsocketbasesavestate}
+Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually written.
 
-\func{void}{SaveState}{\void}
+Use \helpref{Error}{wxsocketbaseerror} to determine if the operation succeeded.
 
-This function saves the current state of the socket in a stack. Socket
-state includes flags, as set with \helpref{SetFlags}{wxsocketbasesetflags},
-event mask, as set with \helpref{SetNotify}{wxsocketbasesetnotify} and
-\helpref{Notify}{wxsocketbasenotify}, and current settings for the
-asynchronous callbacks, as set with \helpref{Callback}{wxsocketbasecallback}
-and \helpref{CallbackData}{wxsocketbasecallbackdata}.
+\wxheading{Parameters}
 
-Calls to SaveState and RestoreState can be nested.
+\docparam{buffer}{Buffer with the data to be sent.}
 
-\wxheading{See also}
+\docparam{nbytes}{Number of bytes.}
 
-\helpref{wxSocketBase::RestoreState}{wxsocketbaserestorestate}
+\wxheading{Return value}
 
-%
-% GetLocal
-%
-\membersection{wxSocketBase::GetLocal}\label{wxsocketbasegetlocal}
+Returns a reference to the current object.
 
-\constfunc{bool}{GetLocal}{\param{wxSockAddress\& }{addr\_man}}
+\wxheading{Remark/Warning}
 
-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, ...).
+The exact behaviour of wxSocketBase::Write depends on the combination
+of flags being used. For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
 
-\wxheading{Return value}
+\wxheading{See also}
 
-It returns TRUE if no errors happened, FALSE otherwise.
+\helpref{wxSocketBase::Error}{wxsocketbaseerror}, 
+\helpref{wxSocketBase::LastError}{wxsocketbaselasterror}, 
+\helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, 
+\helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}
 
 %
-% GetPeer
+% WriteMsg
 %
-\membersection{wxSocketBase::GetPeer}\label{wxsocketbasegetpeer}
-
-\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.
+\membersection{wxSocketBase::WriteMsg}\label{wxsocketbasewritemsg}
 
-% ---------------------------------------------------------------------------
-% Socket callbacks
-% ---------------------------------------------------------------------------
-\membersection{wxSocketBase::SetEventHandler}\label{wxsocketbaseseteventhandler}
+\func{wxSocketBase\&}{WriteMsg}{\param{const void *}{ buffer}, \param{wxUint32}{ nbytes}}
 
-\func{void}{SetEventHandler}{\param{wxEvtHandler\&}{ evt\_hdlr}, \param{int}{ id = -1}}
+This function writes a buffer of {\it nbytes} bytes from the socket, but it
+writes a short header before so that \helpref{ReadMsg}{wxsocketbasereadmsg}
+knows how much data should it actually read. So, a buffer sent with WriteMsg
+{\bf must} be read with ReadMsg. This function always waits for the entire
+buffer to be sent, unless an error occurs.
 
-Sets an event handler to be called when a socket event occurs. The
-handler will be called for those events for which notification is
-enabled with \helpref{SetNotify}{wxsocketbasesetnotify} and
-\helpref{Notify}{wxsocketbasenotify}.
+Use \helpref{LastCount}{wxsocketbaselastcount} to verify the number of bytes actually written.
 
-You can also specify a callback function to be called when an event
-occurs, although if possible, events should be used instead of callbacks.
-See \helpref{Callback}{wxsocketbasecallback} and
-\helpref{CallbackData}{wxsocketbasecallbackdata}.
+Use \helpref{Error}{wxsocketbaseerror} to determine if the operation succeeded.
 
 \wxheading{Parameters}
 
-\docparam{evt\_hdlr}{Specifies the event handler you want to use.}
-
-\docparam{id}{The id of socket event.}
-
-\wxheading{See also}
-
-\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, 
-\helpref{wxSocketBase::Notify}{wxsocketbasenotify}, 
-\helpref{wxSocketEvent}{wxsocketevent}, 
-\helpref{wxEvtHandler}{wxevthandler}, 
-\helpref{wxSocketBase::Callback}{wxsocketbasecallback}, 
-\helpref{wxSocketBase::CallbackData}{wxsocketbasecallbackdata}
-
-\membersection{wxSocketBase::Callback}\label{wxsocketbasecallback}
-
-\func{wxSocketBase::wxSockCbk}{Callback}{\param{wxSocketBase::wxSockCbk}{ callback}}
-
-You can setup a callback function to be called when an event occurs.
-The function will be called only for those events for which notification
-has been enabled with \helpref{Notify}{wxsocketbasenotify} and
-\helpref{SetNotify}{wxsocketbasesetnotify}. The prototype of the
-callback must be as follows:
-
-\begin{verbatim}
-void SocketCallback(wxSocketBase& sock, wxSocketNotify evt, char *cdata);
-\end{verbatim}
-
-The first parameter is a reference to the socket object in which the
-event occured. The second parameter tells you which event occured.
-(See \helpref{wxSocket events}{wxsocketbase}). The third parameter
-is the user data you specified using
-\helpref{CallbackData}{wxsocketbasecallbackdata}.
+\docparam{buffer}{Buffer with the data to be sent.}
 
-Note that events are preferred over callbacks where possible.
+\docparam{nbytes}{Number of bytes to send.}
 
 \wxheading{Return value}
 
-A pointer to the previous callback.
-
-\wxheading{See also}
-
-\helpref{wxSocketBase::CallbackData}{wxsocketbasecallbackdata}, 
-\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, 
-\helpref{wxSocketBase::Notify}{wxsocketbasenotify}
-
-\membersection{wxSocketBase::CallbackData}\label{wxsocketbasecallbackdata}
-
-\func{char *}{CallbackData}{\param{char *}{cdata}}
+Returns a reference to the current object.
 
-This function sets the the user data which will be passed to a
-callback function set via \helpref{Callback}{wxsocketbasecallback}.
+\wxheading{Remark/Warning}
 
-Note that events are preferred over callbacks where possible.
+wxSocketBase::WriteMsg will behave as if the {\bf wxSOCKET\_WAITALL} flag
+was always set and it will always ignore the {\bf wxSOCKET\_NOWAIT} flag.
+The exact behaviour of WriteMsg depends on the {\bf wxSOCKET\_BLOCK} flag.
+For a detailed explanation, see \helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}.
 
-\wxheading{Return value}
+\wxheading{See also}
 
-A pointer to the previous user data.
+\helpref{wxSocketBase::Error}{wxsocketbaseerror}, 
+\helpref{wxSocketBase::LastError}{wxsocketbaselasterror}, 
+\helpref{wxSocketBase::LastCount}{wxsocketbaselastcount}, 
+\helpref{wxSocketBase::SetFlags}{wxsocketbasesetflags}, 
+\helpref{wxSocketBase::ReadMsg}{wxsocketbasereadmsg}
 
-\helpref{wxSocketBase::Callback}{wxsocketbasecallback}, 
-\helpref{wxSocketBase::SetNotify}{wxsocketbasesetnotify}, 
-\helpref{wxSocketBase::Notify}{wxsocketbasenotify}
 
 % ---------------------------------------------------------------------------
 % CLASS wxSocketClient
 % ---------------------------------------------------------------------------
+
 \section{\class{wxSocketClient}}\label{wxsocketclient}
 
 \wxheading{Derived from}
@@ -824,7 +977,7 @@ A pointer to the previous user data.
 %
 \membersection{wxSocketClient::wxSocketClient}
 
-\func{}{wxSocketClient}{\param{wxSockFlags}{ flags = wxSocketBase::NONE}}
+\func{}{wxSocketClient}{\param{wxSocketFlags}{ flags = wxSOCKET_NONE}}
 
 Constructor.
 
@@ -905,10 +1058,29 @@ as set with \helpref{SetTimeout}{wxsocketbasesettimeout}.}
 
 \wxheading{Return value}
 
-If the connection is succesfully established, returns TRUE.
+WaitOnConnect returns TRUE if the connection request completes. This
+does not necessarily mean that the connection was succesfully established;
+it might also happen that the connection was refused by the peer. Use
+\helpref{IsConnected}{wxsocketbaseisconnected} to distinguish between
+these two situations.
 
-If the timeout expires, or if the connection fails, returns FALSE.
-To distinguish between these two conditions, use \helpref{IsConnected}{wxsocketbaseisconnected}
+If the timeout elapses, WaitOnConnect returns FALSE.
+
+These semantics allow code like this:
+
+\begin{verbatim}
+// Issue the connection request
+client->Connect(addr, FALSE);
+
+// Wait until the request completes or until we decide to give up
+bool waitmore = TRUE; 
+while ( !client->WaitOnConnect(seconds, millis) && waitmore )
+{
+    // possibly give some feedback to the user,
+    // and update waitmore if needed.
+}
+bool success = client->IsConnected();
+\end{verbatim}
 
 \wxheading{See also}
 
@@ -954,16 +1126,16 @@ functions that take a wxSocketEvent argument.
 
 Constructor.
 
-\membersection{wxSocketEvent::Socket}\label{wxsocketeventsocket}
+\membersection{wxSocketEvent::GetSocket}\label{wxsocketeventgetsocket}
 
-\constfunc{wxSocketBase *}{Socket}{\void}
+\constfunc{wxSocketBase *}{GetSocket}{\void}
 
 Returns the socket object to which this event refers to. This makes
 it possible to use the same event handler for different sockets.
 
-\membersection{wxSocketEvent::SocketEvent}\label{wxsocketeventsocketevent}
+\membersection{wxSocketEvent::GetSocketEvent}\label{wxsocketeventgetsocketevent}
 
-\constfunc{wxSocketNotify}{SocketEvent}{\void}
+\constfunc{wxSocketNotify}{GetSocketEvent}{\void}
 
 Returns the socket event type.
 
@@ -990,7 +1162,7 @@ Returns the socket event type.
 %
 \membersection{wxSocketServer::wxSocketServer}\label{wxsocketserverconstr}
 
-\func{}{wxSocketServer}{\param{wxSockAddress\&}{ address}, \param{wxSockFlags}{ flags = wxSocketBase::NONE}}
+\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
@@ -1030,7 +1202,7 @@ If {\it wait} is FALSE, it will try to accept a pending connection
 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
+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}