lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] restarting a connection with the raw api


From: Kieran Mansley
Subject: Re: [lwip-users] restarting a connection with the raw api
Date: Fri, 02 Sep 2011 14:56:06 +0100

On Thu, 2011-09-01 at 16:09 -0400, Richie Bonventre wrote:
> I was wondering if anyone knew of any examples using the tcp raw api
> that involved closing and restarting the connection (specifically as
> the client using tcp_connect), as well as properly handling a
> tcp_connect() timeout so that it keeps trying until it successfully
> gets a connection. When in that process do I have to call tcp_new(),
> tcp_close(), when can I safely call tcp_connect() again?

1) First call tcp_new()

2) Then set up the callbacks needed (e.g. by calling tcp_err() to
specific the error callback, and so on)

3) Then call tcp_connect()
 - this will either succeed and call the connected callback passed to
tcp_connect, or fail and call the error callback specified by tcp_err()
 - if the error callback is called because of a timeout I think you
could immediately call tcp_connect() again, but I haven't checked this.

4) When you've finished with a connection, call tcp_close().  After this
returns success you can't touch the pcb struct again, and must call
tcp_new() to get another (i.e. back to step 1).

Hope that helps.  This is all taken from lwip/doc/rawapi.txt, and there
is more detail there.

Kieran




reply via email to

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