Download Source Code

CAsyncWinSock Class Reference

Windows socket API Wrapper. More...

#include <AsyncWinSock.h>

Inheritance diagram for CAsyncWinSock:

Inheritance graph
[legend]
Collaboration diagram for CAsyncWinSock:

Collaboration graph
[legend]
List of all members.

Public Member Functions

BOOL Attach (SOCKET hSocket)
 Attaches to existing socket handle.
void Detach ()
 Detaches from existing socket handle without releasing it.
DWORD GetStatus ()
 Returns the connection status.
BOOL IsConnected ()
 Returns non-zero if the socket is connected.
BOOL IsConnecting ()
 Returns non-zero if the socket is attempting a connection.
BOOL IsSocket ()
 Returns non-zero if the class contains a valid socket handle.
BOOL IsInitialized ()
 Returns non-zero if the Windows Socket API was successfully initialized.
void Destroy ()
 Releases the socket and all other resources.
 CAsyncWinSock ()
 Constructor.
virtual ~CAsyncWinSock ()
 Destructor.
BOOL IoCtlSocket (long cmd, LPDWORD pdw)
 Controls the i/o mode of the socket.
virtual DWORD Send (LPVOID pData, DWORD len=0, LPDWORD sent=NULL, DWORD flags=0)
 Sends the specified buffer over the socket.
virtual DWORD Recv (LPVOID pData, DWORD len, LPDWORD read=NULL, DWORD flags=0)
 Reads data from socket input queue.
BOOL Listen (DWORD dwMaxConnections=8)
 Creates a socket listening on the bound port.
virtual BOOL Connect (PSOCKADDR psai=NULL, DWORD size=0)
 Connects to the specified address.
virtual BOOL CloseSocket (BOOL bBlocking=FALSE, DWORD dwTimeout=3000)
 Closes any open socket.
virtual BOOL OpenSocket (int af=AF_INET, int type=SOCK_STREAM, int protocol=0)
 Creates a new socket handle.
virtual BOOL Accept (CAsyncWinSock *pSocket, SOCKADDR *pSa=NULL, int *nAddr=NULL)
 Call this in response to an OnAccept() message to accept the incomming connection.
BOOL SetBlockingMode (BOOL nonblocking)
 Sets the blocking mode for the socket.
BOOL GetRecvBytesWaiting (LPDWORD pdwBytes)
 Returns the number of bytes waiting to be read.
BOOL GetOOBBytesWaiting (LPDWORD pdwBytes)
 Returns the number of Out-Of-Band bytes waiting to be read.
BOOL IoCtl (DWORD code, LPVOID pInbuf=NULL, DWORD dwInbuf=0, LPVOID pOutbuf=NULL, DWORD dwOutbuf=0, LPDWORD pBytesReturned=NULL)
 Controls Socket2 mode features of the socket.
BOOL EnableCircularQueueing ()
 Enables circular queueing.
BOOL FindRoute (LPSOCKADDR psa)
 Finds the route to the specified address.
BOOL Flush ()
 Flushes the socket data queue.
BOOL GetBroadcastAddress (LPSOCKADDR psa)
 Receives the current broadcast address.
BOOL GetQOS (LPQOS pqos)
 Returns current quality of service information.
BOOL GetGroupQOS (LPQOS pqos)
 Returns current quality of service information.
BOOL SetMultipointLoopback (BOOL bLoopback)
 Enables / disables multi-point loopback.
BOOL SetMultipointScope (DWORD scope)
 Sets multipoint scope.
BOOL SetQOS (LPQOS pqos)
 Sets quality of service information.
BOOL SetGroupQOS (LPQOS pqos)
 Sets group quality of service information.
BOOL EventSelect (WSAEVENT hEvent, long lEvents=FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_CLOSE)
 Selects which events will generate callbacks.
BOOL SetSendBufferSize (DWORD size)
 Sets the send buffer size on the socket.
BOOL SetRecvBufferSize (DWORD size)
 Sets the receive buffer size on the socket.
long GetEnabledCallbacks ()
 Returns a mask indicating the currently active callback events.
void EnableCallbacks (long lEvents=FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_CLOSE)
 Specifies which callback events will be enabled.
void SendMessage (WPARAM wParam, LPARAM lParam)
 Sends a callback message to hooked window or function if any.
void SetCallback (AsyncWinSockCallback f, DWORD user)
 Sets user callback function.
SOCKET GetSocket ()
 Returns the current socket handle or INVALID_HANDLE_VALUE if none.
HANDLE GetEventHandle ()
 Retuns the current event handle.
LPWSANETWORKEVENTS GetEvents ()
 Retunrs a structure describing current network events.
HANDLE GetShutdownHandle ()
 Returns the handle for the socket shutdown event.
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.
DWORD GetLinkCat (LPCTSTR pLink)
 Attempts to determine the link category from the file extension of the specified link.
BOOL OnShutdownEvent ()
 Called on shutdown event.
virtual BOOL OnNetworkEvent (HANDLE hEvent, LPWSANETWORKEVENTS pne)
 Called on network event.
BOOL GetConnectionInfo (LPDWORD pdwAddr, LPDWORD pdwPort, LPSTR pAddr=NULL)
 Gets information about the connected peer.
BOOL Connect (DWORD ip, DWORD port)
 Attempts connection to the specified target address.
BOOL IsRecvData ()
 Returns non-zero if there is data ready to be read.
BOOL CrackUrl (LPCTSTR pUrl)
 Breaks down the specified URL into its components.
BOOL ThreadCloseSocket ()
 Use this function to close the socket from within the callback thread.
BOOL GetSocketName (LPSTR pName, LPDWORD pdwPort=NULL)
 Gets the local socket information.
BOOL GetPeerName (LPSTR pName, LPDWORD pdwPort=NULL)
 Gets the remote socket information.
BOOL SetMessageTarget (HWND hWnd, UINT uMsg)
 Registers a window handle for socket event callbacks.
BOOL StopCallbacks (DWORD dwTimeout=3000)
 Call this function to stop event callbacks.
BOOL StartCallbacks (long lEvents=FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_CLOSE, BOOL bThread=TRUE)
 Call this function to start event callbacks.
BOOL Connect (LPCTSTR pUrl)
 Connects to specified URL.
BOOL GetServeByName (LPCTSTR pName, LPCTSTR pProto, LPSERVENT *pServent=NULL)
 Gets information about the specified address.
BOOL GetHostByName (LPCTSTR pHost, LPDWORD pPort, LPHOSTENT *pHE=NULL)
 Gets host address information from DNS server.
BOOL Bind (DWORD dwPort)
 Binds the open socket to the specified port.
BOOL Connect (LPCTSTR pAddress, DWORD dwPort)
 Address of remote peer.
LPCTSTR GetErrorMsg (DWORD err=0)
 Retuns an error string for the specified error code.
BOOL ThreadShutdown ()
 Call this function from within a thread to shutdown the socket.

Static Public Member Functions

static DWORD GetLocalAddress ()
 Returns the local address of this computer.
static DWORD GetLinkType (LPCTSTR pLink, LPSTR pAdd=NULL)
 Determines the type of link based on the protocal string.
static BOOL GetDomainName (LPCTSTR pLink, LPSTR pDomain)
 Extracts the domain name from the specified link.
static BOOL CrackUrl (LPCTSTR pUrl, LPCRACKURLINFO pcui)
 Breaks down the specified URL into its components.
static BOOL GetErrorMsg (LPSTR pMsg, DWORD err=0, BOOL bLineBreaks=TRUE)
 Returns an information string about the specified error.
static BOOL GetDotAddress (LPCTSTR pHost, LPDWORD pdwIP, LPDWORD pdwPort=NULL)
 Converts dotted address string.

Public Attributes

int m_internalerr [FD_MAX_EVENTS+1]
 Callback internal error codes.

Protected Attributes

HWND m_hWnd
 User callback window handle.
UINT m_uMsg
 User callback window message value.

Detailed Description

Windows socket API Wrapper.

This class provides a wrapper for the Windows Socket API. Callbacks are handled in a thread so there is no need for a Window. This class is reasonably compatible with the MFC CAsyncSocket class.

Warning:
Obsolete, use CWinAsyncSocket instead.


Member Function Documentation

BOOL CAsyncWinSock::Accept CAsyncWinSock pSocket,
SOCKADDR *  pSa = NULL,
int *  nAddr = NULL
[virtual]
 

Call this in response to an OnAccept() message to accept the incomming connection.

Parameters:
[in] pSocket - Pointer to the CAsyncWinSock class that should accept an incomming connection.
[out] pSa - Receives the address of the connecting computer. Can be NULL if not required.
[out] nAddr - Recieves the address of the connecting computer. Can be NULL if not required.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::Attach SOCKET  hSocket  )  [inline]
 

Attaches to existing socket handle.

Parameters:
[in] hSocket - Existing socket handle
Returns:
Returns non-zero if success

BOOL CAsyncWinSock::Bind DWORD  dwPort  ) 
 

Binds the open socket to the specified port.

Parameters:
[in] dwPort - Port to bind to.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::CloseSocket BOOL  bBlocking = FALSE,
DWORD  dwTimeout = 3000
[virtual]
 

Closes any open socket.

Parameters:
[in] bBlocking - Set to non-zero if the function should wait until the socket is released.
[in] dwTimeout - If bBlocking is non-zero, specifies the maximum amount of time, in milli-seconds, to wait for the socket to be released
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::Connect LPCTSTR  pAddress,
DWORD  dwPort
 

Address of remote peer.

Parameters:
[in] pAddress - URL formed address of remote peer.
[in] dwPort - TCP port of remote peer.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::Connect LPCTSTR  pUrl  ) 
 

Connects to specified URL.

Parameters:
[in] pUrl - The URL to connect to.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::Connect DWORD  ip,
DWORD  port
 

Attempts connection to the specified target address.

Parameters:
[in] ip - The ip address of the remote peer.
[in] port - The TCP port of the remote peer.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::Connect PSOCKADDR  psai = NULL,
DWORD  size = 0
[virtual]
 

Connects to the specified address.

Parameters:
[in] psai - The network address of the target computer.
[in] size - Size of the structure in psai.
If psai is NULL, the member variable m_sai is used as the target address.

Returns:
Returns non-zero if success, otherwise zero.

BOOL CAsyncWinSock::CrackUrl LPCTSTR  pUrl  ) 
 

Breaks down the specified URL into its components.

Parameters:
[in] pUrl - The URL to crack.
Result is stored in m_urlc.

Returns:
Returns non-zero if success

BOOL CAsyncWinSock::CrackUrl LPCTSTR  pUrl,
LPCRACKURLINFO  pcui
[static]
 

Breaks down the specified URL into its components.

Parameters:
[in] pUrl - The URL to crack.
[out] pcui - Structure that recieves the URL component information.
Returns:
Returns non-zero if success

void CAsyncWinSock::EnableCallbacks long  lEvents = FD_READ | FD_WRITE | FD_ACCEPT | FD_CONNECT | FD_CLOSE  )  [inline]
 

Specifies which callback events will be enabled.

Parameters:
[in] lEvents - The events to hook.
See also:
EventSelect()
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::EnableCircularQueueing  )  [inline]
 

Enables circular queueing.

Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::EventSelect WSAEVENT  hEvent,
long  lEvents = FD_READ | FD_WRITE | FD_ACCEPT | FD_CONNECT | FD_CLOSE
[inline]
 

Selects which events will generate callbacks.

Parameters:
[in] hEvent - The event handle
[in] lEvents - The events to hook.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::FindRoute LPSOCKADDR  psa  )  [inline]
 

Finds the route to the specified address.

Parameters:
[in] psa - Socket address whose route to find.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::Flush  )  [inline]
 

Flushes the socket data queue.

Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetBroadcastAddress LPSOCKADDR  psa  )  [inline]
 

Receives the current broadcast address.

Parameters:
[out] psa - Receives the current broadcast address
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetConnectionInfo LPDWORD  pdwAddr,
LPDWORD  pdwPort,
LPSTR  pAddr = NULL
 

Gets information about the connected peer.

Parameters:
[out] pdwAddr - The address of the connected peer.
[out] pdwPort - The port of the connected peer.
[out] pAddr - The address string of the connected peer.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetDomainName LPCTSTR  pLink,
LPSTR  pDomain
[static]
 

Extracts the domain name from the specified link.

Parameters:
[in] pLink - The link from which the domain name is extracted.
[out] pDomain - Receives the extracted domain name.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetDotAddress LPCTSTR  pHost,
LPDWORD  pdwIP,
LPDWORD  pdwPort = NULL
[static]
 

Converts dotted address string.

Parameters:
[in] pHost - Address to convert
[out] pdwIP - Receives the IP address.
[out] pdwPort - Receives the TCP port if any.

long CAsyncWinSock::GetEnabledCallbacks  )  [inline]
 

Returns a mask indicating the currently active callback events.

See also:
EventSelect()
Returns:
Returns non-zero if success.

LPCTSTR CAsyncWinSock::GetErrorMsg DWORD  err = 0  )  [inline]
 

Retuns an error string for the specified error code.

Parameters:
[in] err - Error code.
Returns:
Returns the address of a string describing the error code.

BOOL CAsyncWinSock::GetErrorMsg LPSTR  pMsg,
DWORD  err = 0,
BOOL  bLineBreaks = TRUE
[static]
 

Returns an information string about the specified error.

Parameters:
[out] pMsg - Buffer to receive error message string.
[in] err - Error code.
[in] bLineBreaks - Set to non-zero if you want to allow line breaks in the output string.
Returns:
Returns non-zero if err is a valid error code.

BOOL CAsyncWinSock::GetGroupQOS LPQOS  pqos  )  [inline]
 

Returns current quality of service information.

Parameters:
[out] pqos - Recieves quality of service information.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetHostByName LPCTSTR  pHost,
LPDWORD  pPort,
LPHOSTENT *  pHE = NULL
 

Gets host address information from DNS server.

Parameters:
[in] pHost - Address to lookup.
[out] pPort - Receives the TCP port specified in pHost
[out] pHE - Receives the address information.
Returns:
Returns non-zero if success.

DWORD CAsyncWinSock::GetLinkCat LPCTSTR  pLink  ) 
 

Attempts to determine the link category from the file extension of the specified link.

Parameters:
[in] pLink - The link to analzye.
Returns:
Returns the link category.
  • LINKCAT_TXT - Text
  • LINKCAT_IMAGE - Image
  • LINKCAT_NONE - Could not be determined

DWORD CAsyncWinSock::GetLinkType LPCTSTR  pLink,
LPSTR  pAdd = NULL
[static]
 

Determines the type of link based on the protocal string.

Parameters:
[in] pLink - The link to analyze.
[in] pAdd - Added to link before analylzing.
Returns:
Returns the type of link, or zero if unknown.
  • LINKTYPE_HTTP - http://
  • LINKTYPE_FTP - ftp://
  • LINKTYPE_HTTP - www.
  • LINKTYPE_FTP - ftp.
  • LINKTYPE_EMAIL - mailto:
  • LINKTYPE_NEWS - news:
  • LINKTYPE_MMS - mms://

BOOL CAsyncWinSock::GetOOBBytesWaiting LPDWORD  pdwBytes  )  [inline]
 

Returns the number of Out-Of-Band bytes waiting to be read.

Parameters:
[out] pdwBytes - Receives the number of bytes that can be read with a call to Recv(). Must not be NULL.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetPeerName LPSTR  pName,
LPDWORD  pdwPort = NULL
 

Gets the remote socket information.

Parameters:
[out] pName - Receives the remote address of the connected socket.
[out] pdwPort - Receives the remote TCP port of the connected socket.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetQOS LPQOS  pqos  )  [inline]
 

Returns current quality of service information.

Parameters:
[out] pqos - Recieves quality of service information.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetRecvBytesWaiting LPDWORD  pdwBytes  )  [inline]
 

Returns the number of bytes waiting to be read.

Parameters:
[out] pdwBytes - Receives the number of bytes that can be read with a call to Recv(). Must not be NULL.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetServeByName LPCTSTR  pName,
LPCTSTR  pProto,
LPSERVENT *  pServent = NULL
 

Gets information about the specified address.

Parameters:
[in] pName - The name of the server to lookup.
[in] pProto - The name of the protocol to match.
[out] pServent - Receives the information about the address.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::GetSocketName LPSTR  pName,
LPDWORD  pdwPort = NULL
 

Gets the local socket information.

Parameters:
[out] pName - Receives the local address of the connected socket.
[out] pdwPort - Receives the local TCP port of the connected socket.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::IoCtl DWORD  code,
LPVOID  pInbuf = NULL,
DWORD  dwInbuf = 0,
LPVOID  pOutbuf = NULL,
DWORD  dwOutbuf = 0,
LPDWORD  pBytesReturned = NULL
 

Controls Socket2 mode features of the socket.

Parameters:
[in] code - The code of the operation to be performed.
[in] pInbuf - Pointer to the input buffer.
[in] dwInbuf - Size of the buffer in pInBuf.
[in] pOutbuf - Pointer to the output buffer.
[in] dwOutbuf - Size of the buffer in pOutbuf.
[in] pBytesReturned - Number of bytes returned in pOutbuf.
See the Windows Socket API function WSAIoctl() for more details.

Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::IoCtlSocket long  cmd,
LPDWORD  pdw
 

Controls the i/o mode of the socket.

Parameters:
[in] cmd - The command to perform on the socket.
[in,out] pdw - Input and/or return value for cmd.
See the Windows Socket API function ioctlsocket() for more details.

Returns:
Returns non-zero on success, otherwise zero.

BOOL CAsyncWinSock::Listen DWORD  dwMaxConnections = 8  ) 
 

Creates a socket listening on the bound port.

Parameters:
[in] dwMaxConnections - The maximum number of connections allowed.
Returns:
Returns non-zero if success, otherwise zero.
See also:
Bind()

virtual BOOL CAsyncWinSock::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 CAsyncWinSock::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 CAsyncWinSock::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

virtual BOOL CAsyncWinSock::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 CAsyncWinSock::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 CAsyncWinSock::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

BOOL CAsyncWinSock::OnNetworkEvent HANDLE  hEvent,
LPWSANETWORKEVENTS  pne
[virtual]
 

Called on network event.

Parameters:
[in] hEvent - The network event handle.
[in] pne - Network event information.
Returns:
Returns non-zero if event was handled.

virtual BOOL CAsyncWinSock::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 CAsyncWinSock::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 CAsyncWinSock::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

virtual BOOL CAsyncWinSock::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

virtual BOOL CAsyncWinSock::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

BOOL CAsyncWinSock::OpenSocket int  af = AF_INET,
int  type = SOCK_STREAM,
int  protocol = 0
[virtual]
 

Creates a new socket handle.

Parameters:
[in] af - Address family specification.
[in] type - The type specification.
[in] protocol - The protocol to be used with the socket.
Returns:
Returns non-zero if success.

DWORD CAsyncWinSock::Recv LPVOID  pData,
DWORD  len,
LPDWORD  read = NULL,
DWORD  flags = 0
[virtual]
 

Reads data from socket input queue.

Parameters:
[out] pData - Pointer to the buffer that receives the data
[in] len - Length of the buffer in pData in bytes.
[out] read - Number of bytes actually read. Can be NULL.
[in] flags - Read flags
Returns:
Returns the number of bytes read or zero if error.

DWORD CAsyncWinSock::Send LPVOID  pData,
DWORD  len = 0,
LPDWORD  sent = NULL,
DWORD  flags = 0
[virtual]
 

Sends the specified buffer over the socket.

Parameters:
[in] pData - Pointer to the buffer to send.
[in] len - Length of the buffer in pData in bytes.
[out] sent - Receives the number of bytes sent. Can be NULL.
[in] flags - Send flags.
Returns:
Returns the number of bytes sent or zero if error.

BOOL CAsyncWinSock::SetBlockingMode BOOL  nonblocking  )  [inline]
 

Sets the blocking mode for the socket.

Parameters:
[in] nonblocking - Non-zero for non-blocking socket. Zero for blocking socket. This should normally be non-zero.
Returns:
Returns non-zero if success.

void CAsyncWinSock::SetCallback AsyncWinSockCallback  f,
DWORD  user
[inline]
 

Sets user callback function.

Parameters:
f - Address of the callback function. Set to NULL to disable.
user - User data passed to callback function. Hint: set to this pointer.

BOOL CAsyncWinSock::SetGroupQOS LPQOS  pqos  )  [inline]
 

Sets group quality of service information.

Parameters:
[out] pqos - Quality of service information.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::SetMessageTarget HWND  hWnd,
UINT  uMsg
[inline]
 

Registers a window handle for socket event callbacks.

Parameters:
[in] hWnd - The window that will receive callback notifications.
[in] uMsg - Parameter to pass to SendMessage.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::SetMultipointLoopback BOOL  bLoopback  )  [inline]
 

Enables / disables multi-point loopback.

Parameters:
[in] bLoopback - Set to non-zero to enable multi-point loopback.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::SetMultipointScope DWORD  scope  )  [inline]
 

Sets multipoint scope.

Parameters:
[in] scope - Multipoint scope value
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::SetQOS LPQOS  pqos  )  [inline]
 

Sets quality of service information.

Parameters:
[out] pqos - Quality of service information.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::SetRecvBufferSize DWORD  size  )  [inline]
 

Sets the receive buffer size on the socket.

Parameters:
[in] size - The new size of the receive buffer
Returns:
Returns non-zero if success

BOOL CAsyncWinSock::SetSendBufferSize DWORD  size  )  [inline]
 

Sets the send buffer size on the socket.

Parameters:
[in] size - The new size of the send buffer
Returns:
Returns non-zero if success

BOOL CAsyncWinSock::StartCallbacks long  lEvents = FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_CLOSE,
BOOL  bThread = TRUE
 

Call this function to start event callbacks.

Parameters:
[in] lEvents - Socket events to hook.
[in] bThread - Set to non-zero for threaded callbacks
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::StopCallbacks DWORD  dwTimeout = 3000  ) 
 

Call this function to stop event callbacks.

Parameters:
[in] dwTimeout - Amount of time to wait for socket thread to respond that it has received the message. Set to zero if you do not want to wait.
Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::ThreadCloseSocket  ) 
 

Use this function to close the socket from within the callback thread.

Returns:
Returns non-zero if success.

BOOL CAsyncWinSock::ThreadShutdown  )  [inline]
 

Call this function from within a thread to shutdown the socket.

Returns:
Returns non-zero if success.


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