Class CAsyncSocket::
SocketMessageHandler()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: SocketCreatedNext page: SocketWrite    Show member index
Private Function Declared in:
AsyncSocket.h

'Declaration' icon -- Shortcut to top of page. Declaration

static LRESULT CALLBACK SocketMessageHandler(
    HWND hwnd,                          // handle to window
    UINT uMsg,                          // message identifier
    WPARAM wParam,                      // first message parameter
    LPARAM lParam);

'Description' icon -- Shortcut to top of page. Description

Our window proc

'Function Body' icon -- Shortcut to top of page. Function Body

if (m_bShuttingDown)
    return TRUE;

try
{
    //first get the socket
    CAsyncSocket* pSocket;
    pSocket=GetSocketByID((int)wParam);

    //Are we closing ?
    BOOL bIgnore;
    if (pSocket &&
        pSocket->IsClosing() &&
        uMsg!=WM_SOCKET_DELETE)
        bIgnore=TRUE;
    else
        bIgnore=FALSE;

    //Protect the call
    try
    {
        if (pSocket &&
            !bIgnore)
            //Socket exists
            switch (uMsg)
            {
            case WM_SOCKET_FORCED:
                return pSocket->OnSocketReceive(0);
                break;
            case WM_SOCKET_GENERAL:
                if (WSAGETSELECTEVENT(lParam)==FD_READ)
                    return pSocket->OnSocketReceive(WSAGETSELECTERROR(lParam));
                else if (WSAGETSELECTEVENT(lParam)==FD_WRITE)
                    return pSocket->SocketWrite(WSAGETSELECTERROR(lParam));
                else if (WSAGETSELECTEVENT(lParam)==FD_OOB)
                    return pSocket->OnSocketOOB(WSAGETSELECTERROR(lParam));
                else if (WSAGETSELECTEVENT(lParam)==FD_CLOSE)
                    return pSocket->SocketClosed(WSAGETSELECTERROR(lParam));
                break;
            case WM_SOCKET_CONNECT:
                if (WSAGETSELECTEVENT(lParam)==FD_CONNECT)
                    return pSocket->SocketConnected(WSAGETSELECTERROR(lParam));
                break;
            case WM_SOCKET_ACCEPT:
                if (WSAGETSELECTEVENT(lParam)==FD_ACCEPT)
                    return pSocket->OnSocketAccept(WSAGETSELECTERROR(lParam));
                break;
            case WM_TIMER:
                //Do we have a timer ?
                if (pSocket->HasTimeout())
                    //Inform the socket
                    return pSocket->OnSocketTimeout();
                else
                {
                    //Error
                    ReportStaticError("CAsyncSocket_Class","Timeout from previous socket!");

                    //Exit
                    return FALSE;
                }
            case WM_SOCKET_DELETE:
                //Delete the socket
                pSocket->OnSocketDelete();

                //Exit
                return TRUE;
            default:                       /* Passes it on if unproccessed    */
                return (int)(DefWindowProc(hwnd,
                                           uMsg,
                                           wParam,
                                           lParam));
            }
    else
        return (int)(DefWindowProc(hwnd,
                                   uMsg,
                                   wParam,
                                   lParam));
    }
    ERROR_HANDLER_STATIC(CAsyncSocket_Class,"SocketMessageHandler - Proc")

    //Exit
    return TRUE;
}
ERROR_HANDLER_STATIC_RETURN(CAsyncSocket_Class,"SocketMessageHandler",TRUE)

'See Also' icon -- Shortcut to top of page. See Also

Class Overview Class Overview  |  Protected base class CSpoofBase  |  Hierarchy Chart Hierarchy Chart


Get Surveyor!This web site was generated using Surveyor V4.50.811.1.  Click here for more information. Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003.