lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Netconn API and nonblocking connect - how to proceed after


From: Marco Jakobs
Subject: [lwip-users] Netconn API and nonblocking connect - how to proceed after unsuccessful connection
Date: Mon, 23 Jul 2012 16:40:23 +0200

Hi,

 

i'm coding around with the nonblocking TCP connect and the use of the callback routine. As the possible cases are not very well documented, I've got stuck in a situation after an unsuccessful netconn_connect as follows:

 

A handler should try to connect a TCP server. if the connection fails, it should retry periodically to connect again to this client with some seconds of waiting between the attempts.

 

This is how I did this:

 

1. Getting a new netconn for the connection
            ssrv_netconn[nconn-1].conn = netconn_new_with_callback (NETCONN_TCP, ssrv_tcpcln_callback);                // Connection neu

 

2. Set the connection to nonblocking
            netconn_set_nonblocking(ssrv_netconn[nconn-1].conn, 1);

 

3. Try to connect to the remote host
            err = netconn_connect (ssrv_netconn[ssrv_conn[f].netconn[0]-1].conn, &ssrv_addr, port);                    // Verbindung öffnen

            err returns as -4 (in progress)

            As the host is not running a service on this port, the callback immediately returns the ERROR

 

4. The ERROR causes the handler to wait the given seconds for this connection

 

5. For the next attempt, go again to step 3 (netconn_connect) to try again to connect

            -> But now I'm always getting back the error code -12 (ERR_CLSD).

 

Why are the second and any following attempts not working and why do I always get back the ERR_CLSD without any connection attempts?


reply via email to

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