tcp_connect failure not calling connected callback

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

tcp_connect failure not calling connected callback

David-358
Hello all,

when tcp_connect is called the stack is supposed to
call the connected callback function with an error
code if the connection can not be made or is rst. at
least that's what it says in the rawapi.txt. instead
the errf callback is called. is the doc just out dated
or is this a mistake ?

thanks
davidb


       
____________________________________________________________________________________Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow 


_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

RE : tcp_connect failure not calling connected callback

Frédéric BERNON
Hi,

>From memory, with callback api (LWIP_CALLBACK_API=1, which is the default value), tcp_connect is asynchrone (the function return without waiting a error condition or the real connection).

If you want a "sample" for that, look api_msg.c file (the "raw" part of the sequential api). If I resume, a tcp client would be initialize like this (no error checking to simplify):

tcp_pcb* pcb = tcp_new();
tcp_arg(pcb, your_arg); /* "your_arg" is a "user data", any value you want to get when callbacks are invoked */
tcp_recv(pcb, recv_tcp); /* set "recv callback" */
tcp_sent(pcb, sent_tcp); /* set "send callback" */
tcp_poll(pcb, poll_tcp, 4); /* set "poll callback" */
tcp_err(pcb, err_tcp);   /* set "error callback" */
tcp_bind(pcb, ipaddr, port);
tcp_connect(pcb, ipaddr, port, do_connected); /* set "connected callback" */

After that, the final "result" is known when "do_connected" XOR "err_tcp" is called. If you really want to be sure, process both cases (do_connected with err!=ERR_OK, and err_tcp), and in general, in any callback which provide an erro code (like recv_tcp)...
 
 
====================================
Frédéric BERNON
HYMATOM SA
Chef de projet informatique
Microsoft Certified Professional
Tél. : +33 (0)4-67-87-61-10
Fax. : +33 (0)4-67-70-85-44
Email : [hidden email]
Web Site : http://www.hymatom.fr 
====================================
P Avant d'imprimer, penser à l'environnement
 


-----Message d'origine-----
De : lwip-devel-bounces+frederic.bernon=[hidden email] [mailto:lwip-devel-bounces+frederic.bernon=[hidden email]] De la part de David
Envoyé : jeudi 31 mai 2007 22:18
À : [hidden email]
Objet : [lwip-devel] tcp_connect failure not calling connected callback


Hello all,

when tcp_connect is called the stack is supposed to
call the connected callback function with an error
code if the connection can not be made or is rst. at
least that's what it says in the rawapi.txt. instead
the errf callback is called. is the doc just out dated
or is this a mistake ?

thanks
davidb


       
____________________________________________________________________________________Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games. http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow 


_______________________________________________
lwip-devel mailing list
[hidden email] http://lists.nongnu.org/mailman/listinfo/lwip-devel

_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel

=?iso-8859-1?Q?Fr=E9d=E9ric_BERNON=2Evcf?= (810 bytes) Download Attachment