lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] advice on recovery on a socket send error using tcp_write()


From: shogun
Subject: [lwip-users] advice on recovery on a socket send error using tcp_write()
Date: Wed, 18 Aug 2010 19:11:26 -0400

I have a couple questions about getting an error on tcp_write() using lwip.


Sometimes I get an (0xFF) error from the send function:

//this is sudo code here
ert = tcp_write(my_pcb, data, size, 0);
if(ert) 
{
        close_socket()
}


I do not yet know if the error is on the embedded lwip side (server) or the
PC side (client). I think it's more likely on the embedded side since I
usually cannot get the socket to recover until I reset the embedded side.

My questions are:

1) What is recommended to clean up after a error on a socket? I was doing
something like the example here and calling close_socket() but it doesn't
work well.  I would like to close the socket and reinitialize it to
reestablish communication.


static void close_socket(struct tcp_pcb *pcb)
{
        tcp_arg(pcb, NULL);     
        tcp_sent(pcb, NULL);
        tcp_close(pcb);
        socket_init();  //This will re init the socket with tcp_new() etc.
} //end debug_client_close()


The above function would be called if a connection is lost, there is an
error etc.  The
goal is to keep the communication working between the two systems and if
necessary have the remote client reestablish the connection.  The function
socket_init() does the full initialization like it does when the socket is
first initialized on startup.
tcp_new();
tcp_bind();
tcp_listen();
tcp_accept();


2) My other question is what would be the likely cause of the tcp_write()
returning 0xFF?

Thanks for your help!







reply via email to

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