lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Problem with tcp_bind()


From: Yafei Yan
Subject: Re: [lwip-users] Problem with tcp_bind()
Date: Thu, 31 Oct 2013 10:06:17 +0800

Hi,

When you call tcp_close(), the socket is not close immediately. The tcp connection will come into TCP_WAIT,  after few minitues the connection will close completely and free the socket.
If you want to call tcp_bind() directly after call tcp_close, you can configure the socket attribute "SO_REUSE" as follow:
/**
 * SO_REUSE==1: Enable SO_REUSEADDR option.
 */
#ifndef SO_REUSE
#define SO_REUSE                        1
#endif


Yafei


2013/10/31 Hugh Reynolds <address@hidden>

My application works fine but…

 

I have LWIP running on my ARM platform and it talks to my PC application just fine.

I’m send the PC an unsolicited message every second.

 

If my PC connection gets lost…i.e. I pull the network cable out of the PC

I get the expected error next time I call tcp_write().

I call tcp_close() and drop back to my loop listening for a connection which is (simplified)

 

err_t tcp_listen_init(void)

{

err_t error;

struct tcp_pcb* ptel_pcb;

 

ptel_pcb = tcp_new();

if (ptel_pcb != NULL)

  {

      error = tcp_bind(ptel_pcb, IP_ADDR_ANY, PORT1);

    }

  if (error == ERR_OK)

    {

    ptel_pcb = tcp_listen(ptel_pcb);

    tcp_arg(ptel_pcb, ptel_pcb);

    tcp_accept(ptel_pcb, accept);

    printf("[Ttcp_listen_init started: PORT = %05d]\n", PORT1);

      }

    }

  else

    {

    //**********************

    printf("[TUnable to Bind for tcp_listen_init]\n”);

    tcp_close(ptel_pcb);

    }

  }

else

  {

  error = ERR_MEM;

  printf("[TNo memory for tcp_listen_init]\n");

  }

return error;

}

 

I get stuck in a loop allways hitting the statements below     //**********************

tcp_bind() is reporting ERR_USE from the ‘address already is in use’ term

 

Any idea how to close/abort/abandon the link if the cable is pulled out of the PC without getting into this loop I am in?

 

Regards

 

Hugh

 


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users


reply via email to

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