[help]ERROR:mismatch between message and socket?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

[help]ERROR:mismatch between message and socket?

Post by lfjking »

The Running Error:mismatch between message and socket?
the code:

Code: Select all

//src/msw/sockmsw.cpp
/* Windows proc for asynchronous event handling */

LRESULT CALLBACK wxSocket_Internal_WinProc(HWND hWnd,
                                           UINT uMsg,
                                           WPARAM wParam,
                                           LPARAM lParam)
{
    if ( uMsg < WM_USER || uMsg > (WM_USER + MAXSOCKETS - 1))
        return DefWindowProc(hWnd, uMsg, wParam, lParam);

    wxSocketImplMSW *socket;
    wxSocketNotify event = (wxSocketNotify)-1;
    {
        wxCRIT_SECT_LOCKER(lock, gs_critical);

        socket = socketList[(uMsg - WM_USER)];
        if ( !socket )
            return 0;

        // the socket may be already closed but we could still receive
        // notifications for it sent (asynchronously) before it got closed
        if ( socket->m_fd == INVALID_SOCKET )
            return 0;

        wxASSERT_MSG( socket->m_fd == (SOCKET)wParam,
                      "mismatch between message and socket?" );		//<-------------------Error here----------------

        switch ( WSAGETSELECTEVENT(lParam) )
        {
            case FD_READ:
                // We may get a FD_READ notification even when there is no data
                // to read on the socket, in particular this happens on socket
                // creation when we seem to always get FD_CONNECT, FD_WRITE and
                // FD_READ notifications all at once (but it doesn't happen
                // only then). Ignore such dummy notifications.
                {
                    fd_set fds;
                    timeval tv = { 0, 0 };

                    wxFD_ZERO(&fds);
                    wxFD_SET(socket->m_fd, &fds);

                    if ( select(socket->m_fd + 1, &fds, NULL, NULL, &tv) != 1 )
                        return 0;
                }

                event = wxSOCKET_INPUT;
                break;

            case FD_WRITE:
                event = wxSOCKET_OUTPUT;
                break;

            case FD_ACCEPT:
                event = wxSOCKET_CONNECTION;
                break;

            case FD_CONNECT:
                event = WSAGETSELECTERROR(lParam) ? wxSOCKET_LOST
                                                  : wxSOCKET_CONNECTION;
                break;

            case FD_CLOSE:
                event = wxSOCKET_LOST;
                break;

            default:
                wxFAIL_MSG( "unexpected socket notification" );
                return 0;
        }
    } // unlock gs_critical

    socket->NotifyOnStateChange(event);

    return 0;
}
I don't know what caused the mistake。
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: [help]ERROR:mismatch between message and socket?

Post by ONEEYEMAN »

Hi,
Usual stanza:

What is you wx version?
What OS are trying this on?
Do you have firewall running?

And of course - can you reproduce it in the socket sample ( with possible minimal changes)?

Thank you.
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

Re: [help]ERROR:mismatch between message and socket?

Post by lfjking »

ONEEYEMAN wrote:Hi,
Usual stanza:

What is you wx version?
What OS are trying this on?
Do you have firewall running?

And of course - can you reproduce it in the socket sample ( with possible minimal changes)?

Thank you.
Hi,
I use wx3.10 in Win7-64 .
No firewall.
and ,My project has a lot of Socket connections.
So I don't know what caused it.
but, this is only in debug but not release.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: [help]ERROR:mismatch between message and socket?

Post by ONEEYEMAN »

Hi,
Are you able to execute a server/client sample from wxWidgets distribution?
If you are - can you make it to produce the same issue?

Thank you.
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

Re: [help]ERROR:mismatch between message and socket?

Post by lfjking »

ONEEYEMAN wrote:Hi,
Are you able to execute a server/client sample from wxWidgets distribution?
If you are - can you make it to produce the same issue?

Thank you.

Sorry, I can't make the same issue.
So I don't know what's the problem, too.
But luckily it's just a warning, release is okay.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: [help]ERROR:mismatch between message and socket?

Post by ONEEYEMAN »

Hi,
If you have a problem in the Debug build - most likely the Release version just hides it.

Try to find what the problem is by looking at the sample (if you were able to run it successfully) and your code.

Thank you.
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

Re: [help]ERROR:mismatch between message and socket?

Post by lfjking »

ONEEYEMAN wrote:Hi,
If you have a problem in the Debug build - most likely the Release version just hides it.

Try to find what the problem is by looking at the sample (if you were able to run it successfully) and your code.

Thank you.
Yes, I need to do that. Thanks very much
Post Reply