CWinAsyncSocket Class ReferenceProvides asynchronous socket communications.
More...
#include <WinAsyncSocket.h>
Inheritance diagram for CWinAsyncSocket:
[legend]Collaboration diagram for CWinAsyncSocket:
[legend]List of all members.
|
Public Types |
| enum | { eCmdNone = 0,
eCmdOpen,
eCmdClose
} |
| enum | { eStatusDisconnected = 0,
eStatusConnecting,
eStatusConnected
} |
Public Member Functions |
|
| CWinAsyncSocket () |
| | Default constructor.
|
|
virtual | ~CWinAsyncSocket () |
| | Destructor.
|
| virtual BOOL | InitThread (LPVOID pData) |
| | Initializes the thread.
|
| virtual BOOL | DoThread (LPVOID pData) |
| | Processes socket information.
|
| virtual BOOL | EndThread (LPVOID pData) |
| | Provides thread cleanup.
|
| BOOL | Connect (LPCTSTR pIpAddress, UINT uPort) |
| | Connects the socket to the specified address.
|
| BOOL | Close () |
| | Closes the socket.
|
|
CWinSocket * | GetSocket () |
| | Returns a pointer to the encapsulated CWinSocket class.
|
| 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.
|
| virtual BOOL | OnOOB (int nErr) |
| | Called when Out-Of-Band data has been received from connected socket.
|
| virtual BOOL | OnAccept (int nErr) |
| | Called when an incomming connection request is recieved.
|
| virtual BOOL | OnConnect (int nErr) |
| | Called when the socket has connection has completed, or failed.
|
| virtual BOOL | OnClose (int nErr) |
| | Called when socket connection has been closed or aborted.
|
| virtual BOOL | OnQOS (int nErr) |
| | Called when Quality-Of-Service parameters has changed.
|
| virtual BOOL | OnGroupQOS (int nErr) |
| | Called when group Quality-Of-Service parameters has changed.
|
| virtual BOOL | OnRoutingInterfaceChange (int nErr) |
| | Called when the routing interface parameters have changed.
|
| virtual BOOL | OnAddressListChange (int nErr) |
| | Called when the multi-cast address list has changed.
|
| virtual BOOL | OnError (WORD wEvent) |
| | Called on socket error.
|
| 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.
|
|
UINT | GetStatus () |
| | Gets the socket connection status.
|
|
BOOL | IsConnected () |
| | Returns non-zero if the socket is connected.
|
|
BOOL | IsConnecting () |
| | Returns non-zero if the socket is connecting.
|
Protected Member Functions |
| BOOL | OnCommand () |
| | Processes a command from the command queue.
|
| BOOL | OnSocketEvent () |
| | Processes socket events.
|
Classes |
| struct | SCmdData |
| | This structure holds information about a thread command. More...
|
Detailed Description
Provides asynchronous socket communications.
This class uses CWinSocket and provides a thread to handle socket data.
You can derive from this class or more preferably, derive from CWinSocketProtocol and provide custom protocol handling. This scheme works well for both TCP and UDP based protocols.
- See also:
- TWinAsyncSocket, CWinSocketProtocol, CWinSocket
Member Enumeration Documentation
|
|
- Enumerator:
-
| eCmdNone |
Invalid command ID. |
| eCmdOpen |
Open connection. |
| eCmdClose |
Close connection. |
|
|
|
- Enumerator:
-
| eStatusDisconnected |
Socket is not connected. |
| eStatusConnecting |
Socket is connecting. |
| eStatusConnected |
Socket is connected. |
|
Member Function Documentation
| BOOL CWinAsyncSocket::Close |
( |
|
) |
|
|
|
|
Closes the socket.
- Returns:
- Non-zero if command was queued
- See also:
- Connect()
|
| BOOL CWinAsyncSocket::Connect |
( |
LPCTSTR |
pIpAddress, |
|
|
UINT |
uPort |
|
) |
|
|
|
|
Connects the socket to the specified address.
- Parameters:
-
| [in] | pIpAddress | - Remote address |
| [in] | uPort | - Connection port |
- Returns:
- Non-zero if command was queued
- See also:
- Close()
|
| BOOL CWinAsyncSocket::DoThread |
( |
LPVOID |
pData |
) |
[virtual] |
|
|
|
Processes socket information.
- Parameters:
-
- Returns:
- Non-zero to continue the thread
- See also:
Reimplemented from CThread. |
| BOOL CWinAsyncSocket::EndThread |
( |
LPVOID |
pData |
) |
[virtual] |
|
|
|
Provides thread cleanup.
- Parameters:
-
- Returns:
- Ignored
- See also:
Reimplemented from CThread. |
| virtual HANDLE CWinAsyncSocket::GetDataReadyHandle |
( |
|
) |
[inline, virtual] |
|
|
|
Return a valid handle if you want to receive data tx messages.
- Returns:
- Waitable event handle
- See also:
Reimplemented in TWinAsyncSocket< T >. |
| BOOL CWinAsyncSocket::InitThread |
( |
LPVOID |
pData |
) |
[virtual] |
|
|
|
Initializes the thread.
- Parameters:
-
- Returns:
- Non-zero to continue the thread
- See also:
Reimplemented from CThread. |
| virtual BOOL CWinAsyncSocket::OnAccept |
( |
int |
nErr |
) |
[inline, virtual] |
|
|
|
Called when an incomming connection request is recieved.
- Parameters:
-
| [in] | nErr | - Zero if no error, otherwise socket error value. |
You should call Accept in response to this callback.
- Returns:
- Return non-zero if handled
|
| virtual BOOL CWinAsyncSocket::OnAddressListChange |
( |
int |
nErr |
) |
[inline, virtual] |
|
|
|
Called when the multi-cast address list has changed.
- Parameters:
-
| [in] | nErr | - Zero if no error, otherwise socket error value. |
- Returns:
- Return non-zero if handled
|
| virtual BOOL CWinAsyncSocket::OnClose |
( |
int |
nErr |
) |
[inline, virtual] |
|
|
|
Called when socket connection has been closed or aborted.
- Parameters:
-
| [in] | nErr | - Zero if no error, otherwise socket error value. |
- Returns:
- Return non-zero if handled
|
| BOOL CWinAsyncSocket::OnCommand |
( |
|
) |
[protected] |
|
|
|
Processes a command from the command queue.
- Returns:
- Non-zero if success
- See also:
|
| virtual BOOL CWinAsyncSocket::OnConnect |
( |
int |
nErr |
) |
[inline, virtual] |
|
|
|
Called when the socket has connection has completed, or failed.
- Parameters:
-
| [in] | nErr | - Zero if no error, otherwise socket error value. |
- Returns:
- Return non-zero if handled
|
| virtual BOOL CWinAsyncSocket::OnDataReady |
( |
|
) |
[inline, virtual] |
|
| virtual BOOL CWinAsyncSocket::OnError |
( |
WORD |
wEvent |
) |
[inline, virtual] |
|
|
|
Called on socket error.
- Parameters:
-
| [in] | wEvent | - Zero if no error, otherwise socket error value. |
- Returns:
- Return non-zero if handled
|
| virtual BOOL CWinAsyncSocket::OnGroupQOS |
( |
int |
nErr |
) |
[inline, virtual] |
|
|
|
Called when group Quality-Of-Service parameters has changed.
- Parameters:
-
| [in] | nErr | - Zero if no error, otherwise socket error value. |
- Returns:
- Return non-zero if handled
|
| virtual BOOL CWinAsyncSocket::OnOOB |
( |
int |
nErr |
) |
[inline, virtual] |
|
|
|
Called when Out-Of-Band data has been received from connected socket.
- Parameters:
-
| [in] | nErr | - Zero if no error, otherwise socket error value. |
- Returns:
- Return non-zero if handled
|
| virtual BOOL CWinAsyncSocket::OnQOS |
( |
int |
nErr |
) |
[inline, virtual] |
|
|
|
Called when Quality-Of-Service parameters has changed.
- Parameters:
-
| [in] | nErr | - Zero if no error, otherwise socket error value. |
- Returns:
- Return non-zero if handled
|
| virtual BOOL CWinAsyncSocket::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 in TWinAsyncSocket< T >. |
| virtual BOOL CWinAsyncSocket::OnRoutingInterfaceChange |
( |
int |
nErr |
) |
[inline, virtual] |
|
|
|
Called when the routing interface parameters have changed.
- Parameters:
-
| [in] | nErr | - Zero if no error, otherwise socket error value. |
- Returns:
- Return non-zero if handled
|
| BOOL CWinAsyncSocket::OnSocketEvent |
( |
|
) |
[protected] |
|
|
|
Processes socket events.
- Returns:
- Non-zero if success
- See also:
|
| virtual BOOL CWinAsyncSocket::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 in TWinAsyncSocket< T >. |
The documentation for this class was generated from the following files:
- inc/WinAsyncSocket.h
- WinAsyncSocket.cpp
|