lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: Possible to have netconn_recv unblocking?


From: Dany Thiffeault
Subject: [lwip-users] Re: Possible to have netconn_recv unblocking?
Date: Fri, 2 Oct 2009 14:05:02 -0400

ok, maybe I posted my question a little early. I figured it out and it's working fine. For the record, here is what I did:

1- Changed LWIP_SO_RCVTIMEO  to '1';
2- Since I want to "netconn_accept()" call to be blocking, I did this, where pNetConnListener is a struct netconn*:

// Put a timeout of 0 to force a blocking accept.
pNetConnListener->recv_timeout = 0;
pNetConnListenerNewConn = netconn_accept(pNetConnListener);

3- Since I want a non-blocking "netconn_recv()", I did this:

// Check for incoming frames.
pNetConnListenerNewConn->recv_timeout = receiveTimeoutInMs;
pNetBuffer = netconn_recv(pNetConnListenerNewConn);
if (pNetBuffer != NULL)
{
    .......
}
else
{
    // Detect if there was a problem or it's because there was no data.
    if (pNetConnListenerNewConn->err == ERR_TIMEOUT)
    {
        // No data received. Since we should receive a keep alive packet every x seconds,
        // this mean that the host has a problem or the connection has been broken
        // (disconnected cable for example). Disconnect and prepare for next connection.
        break;
    }
    else
    {
        // For any other errors, it's a problem. Disconnect and prepare for next connection.
        //print_dbg("CommManager - ListenerTask Connection Problem.\n\r");
        break;
    }
}

My search of LWIP_SO_RCVTIMEO indicated that it's not used anywhere else that needs attention (except for the netconn_accept()). So, now I can disconnect and reconnect my cable at will!

Hope this helps some others!




On Fri, Oct 2, 2009 at 11:44 AM, Dany Thiffeault <address@hidden> wrote:
Hey,

I was testing the stability of my system, so I disconnected the Ethernet cable from my lwIP device and reconnected it. I found out that the connection wasn't re-initializing itself. I foudn out that my task is blocked in netconn_recv() indefinatly.

I absolutly need to be able to detect a network fault and go back into connection accepting state. I searched around and found threads about this exact question, but the replies were all: swith to raw API. 

This is not good for me, since I'm using a multi-task system with RTOS, sequential API.

My LWIP_SO_RCVTIMEO is 0 currently, and according to the code, it looks like I could put this to 1 and not block. But I just want to use it on the netconn_recv() call, no others...

Any advice here? Is it the way to go?
Thanks!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]