Download Source Code

TWinAsyncSocket< T > Class Template Reference

Provides asynchronous socket communications. More...

#include <WinAsyncSocket.h>

Inheritance diagram for TWinAsyncSocket< T >:

Inheritance graph
[legend]
Collaboration diagram for TWinAsyncSocket< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TWinAsyncSocket ()
 Default constructor.
 ~TWinAsyncSocket ()
 Destructor.
T * Protocol ()
 Returns a pointer to the protocol interface.
virtual HANDLE GetDataReadyHandle ()
 Return a valid handle if you want to receive data tx messages.
virtual BOOL OnDataReady ()
 Called when the event handle returned by GetDataReadyHandle() is set.
virtual BOOL OnRead (int nErr)
 Called when data has been received from connected socket.
virtual BOOL OnWrite (int nErr)
 Called when previously full transmit buffer is now empty.

Detailed Description

template<class T>
class TWinAsyncSocket< T >

Provides asynchronous socket communications.

This class derives from CWinAsyncSocket and provides an interface to CWinSocketProtocol derived classes. See CWinSocket for synchronous socket.

Example:

    // Create stream socket
    TWinAsyncSocket< CWspStream > wasStream;

    wasStream.Connect( "google.com", 80 );

    Sleep( 1000 );

    wasStream.GetProtocol()->Write( "GET / HTTP/1.0\r\n\r\n" );

    Sleep( 1000 );

    UINT uRead = 0;
    char szBuf[ 8 * 1024 ];
    wasStream.GetProtocol()->Read( szBuf, sizeof( szBuf ), &uRead );

    printf( szBuf );

    \see CWinAsyncSocket, CWinSocketProtocol, CWinSocket


Member Function Documentation

template<class T>
virtual HANDLE TWinAsyncSocket< T >::GetDataReadyHandle  )  [inline, virtual]
 

Return a valid handle if you want to receive data tx messages.

Returns:
Waitable event handle
See also:

Reimplemented from CWinAsyncSocket.

template<class T>
virtual BOOL TWinAsyncSocket< T >::OnDataReady  )  [inline, virtual]
 

Called when the event handle returned by GetDataReadyHandle() is set.

Returns:
Non-zero if success
See also:

Reimplemented from CWinAsyncSocket.

template<class T>
virtual BOOL TWinAsyncSocket< T >::OnRead int  nErr  )  [inline, virtual]
 

Called when data has been received from connected socket.

Parameters:
[in] nErr - Zero if no error, otherwise socket error value.
Returns:
Return non-zero if handled

Reimplemented from CWinAsyncSocket.

template<class T>
virtual BOOL TWinAsyncSocket< T >::OnWrite int  nErr  )  [inline, virtual]
 

Called when previously full transmit buffer is now empty.

Parameters:
[in] nErr - Zero if no error, otherwise socket error value.
Returns:
Return non-zero if handled

Reimplemented from CWinAsyncSocket.


The documentation for this class was generated from the following file:
  • inc/WinAsyncSocket.h
Copyright Robert Umbehant
This documentation is covered by the LGPL