|
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.
|
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.