I try this before.  It works.

in tcp.c

err_t
tcp_close(struct tcp_pcb *pcb)
{
 ....
  case ESTABLISHED:
    if( rstClose & 0x1) // rstClose is a control flag.
    {
        err = tcp_send_ctrl(pcb, TCP_FIN);
        if (err == ERR_OK) {
          snmp_inc_tcpestabresets();
          pcb->state = FIN_WAIT_1;
        }
    }
    else
    {
        tcp_abort(pcb);
        err = ERR_OK;
        pcb = NULL;
    }
    break;
...
}


I ask the similar question before.  For the TCP/IP standard, the FIN is a
good solution.  But the RST is a shotcut solution in certain environment.





On Wed, Dec 8, 2010 at 10:53 PM, Jeff Barber <[email protected]> wrote:

> On Tue, Dec 7, 2010 at 10:23 PM, runjin <[email protected]> wrote:
> > I found that closesocket sends a FIN packet,
> > How to send RST ?
>
> AFAIK, there is no way to send RST using the socket or netconn APIs.
> But then this is not something that is normally available to
> applications in other OSes like Linux or Windows either.  (If you're
> using the raw API, you can call tcp_abort. However, that's not
> something you can mix with the other APIs.)
>
> What are you trying to accomplish by sending a RST?
>
> Jeff
>
> _______________________________________________
> lwip-users mailing list
> [email protected]
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to