lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] tcp_connection (no SYN packet on server side)


From: Sergio R. Caprile
Subject: Re: [lwip-users] tcp_connection (no SYN packet on server side)
Date: Mon, 4 Jun 2018 11:58:04 -0300
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

That may or may not work depending on what your _magic function_
"delay_ms" does. If it is blocking, you are busted.

A main loop is a main loop, you need to rx and you need to check
timeouts. Your accept callback will be called after the SYN is SYNACKed
and the SYNACK is ACKed back. For that, you need to have the stack
running, otherwise no one can send anything, and that is done by calling
sys_check_timeouts() as frequently as you can. And you need to rx for
the SYNACK, which is done by calling ethernetif_input() frequently
enough in order not to lose frames. That can't happen if you are blocking.

If you really want to sequentially check for whatever reason, you can do
this:

udp_cb_called = tcp_cb_called = false;

IP4_ADDR(&ip, ETH_CONF_IPADDR0, ETH_CONF_IPADDR1, ETH_CONF_IPADDR2, 155);
err = tcp_connect(pcb_tcp, &ip, ETH_TCP_PORT_REM, tcp_connected_cb);
if (err != ERR_OK) {
        // Oops
}

while(udp_cb_called == false && tcp_cb_called == false) {
        ethernetif_input(&dev_netif);
        sys_check_timeouts();
}

Your second attempt to call connect will fail as your pcb is being used,
so that won't work inside a loop (and a bit involved to explain in one
line). And I guess you'll set tcp_cb_called to "true" somewhere in your
tcp_connected_cb()

However, that is not much different from a real main loop:

while(1) {
        ethernetif_input(&dev_netif);
        if(whatiamexpectinghashappened)
                ; // bingo!
        sys_check_timeouts();
        world_save();
        stuff_do();
        morestuff_moredo();
}




reply via email to

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