[Top][All Lists]

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

[lwip-devel] [bug #26069] Documentation of tcp_connect() incorrectly des

From: Iordan Neshev
Subject: [lwip-devel] [bug #26069] Documentation of tcp_connect() incorrectly describes handling of errors
Date: Mon, 06 Apr 2009 08:44:18 +0000
User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon; .NET CLR 2.0.50727)

Follow-up Comment #15, bug #26069 (project lwip):

this is a bit of my experience, I hope
it will help:

First I allocate a socket descriptor, associated
with a static application buffer (not a pbuf):

sockfd_t cb_sock(...) // allocate a socket
    ... ...
    tcp_recv(cb_Sockets[sockfd].pcb, CB_active_recv);   
    tcp_err (cb_Sockets[sockfd].pcb, CB_errhanler);

int cb_connect(int sockfd,  struct sockaddr_in *ptr_sockaddr_remote)
    err = tcp_connect(cb_Sockets[sockfd].pcb, &remote_ipaddr,
            port, CB_active_connected);

According to rawapi.h CB_active_connected() should be
called with (err != ERR_OK). In my application this
never happens. The error handler (CB_errhanler) is
called instead. For me it just sets one of the higher-level 
application error flags. I check it everytime I use
the socket to send or receive data. 

Simply, depending on the place
where whatever problem is detected a different type of
flags are rised, eventually tcp_close() and/or tcp_abort()
may be called. The poll handler clears any garbage after
some timeout if needed, allowing the application to get any
buffered received data. The process is much complicated for
me since it must handle also other events such as 
remote close requests and local close or shutdown request.

Keep in mind that "The error callback function does not get the pcb passed to
it as a parameter since the pcb may already have been deallocated. ..."

I use the "almost" latest version of lwip - about a month ago.



Reply to this item at:


  Message sent via/by Savannah

reply via email to

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