This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

tcp_close and tcp_abort doesn't work properly

Hi

I've used At91sam7x512 and keil sample codes for TCP connection but here is a kind of problem when I try to disconnect my board in my tcp_callback routine I'll get TCP_EVT_CLOSE condition and here I called tcp_close(soc)

when I use tcp_get_state before tcp_close the result is 10 (TCP_STATE_CONNECT) and after that it's 255 (!!!)

and if I wait for 2 or more minutes my tcp_callback have been called again but with TCP_EVT_ABORT condition.

during this time gap, I'm in listening mode but nobody can connect to my device.

below code is a part of my work and I used printf to get state of tcp in different positions:

case TCP_EVT_CLOSE:
printf("1:%d\r\n",tcp_get_state(soc));
tcp_close(soc);
tcp_release_cocket(soc);
printf("2:%d\r\n",tcp_get_state(soc));
initializetcp();
.
.
.
case TCP_EVT_ABORT:
printf("3:%d\r\n",tcp_get_state(soc));
tcp_abort(soc);
tcp_release_cocket(soc);
printf("4:%d\r\n",tcp_get_state(soc));
initializetcp();
.
.
.

and in initializetcp routine I try to get socket and listen. and I've used tcp_abort instead of tcp_close in TCP_EVT_CLOSE condition but they were the same and the problem was exist

and I've got such a result from hyperteminal:

1:10
2:255


(after 2 minute)

3:8
4:255

although when I try to close my program in PC there is no any problem but when my application program throw an exception such problem will occur.

what's going wrong here?

thanks in advance

Parents
  • "TCP RFC said as a keepalive packet you can send a packet with no any data or with garbage data"

    That's not quite how I remember it being described!?

    Data is data is data. How can you send garbage data? How would any TCP stack know that an application is sending garbage data as opposed to non-garbage data?

    TCPnet is definitely NOT unusual in NOT providing a facility to issue keepalive packets at will from within an application.

Reply
  • "TCP RFC said as a keepalive packet you can send a packet with no any data or with garbage data"

    That's not quite how I remember it being described!?

    Data is data is data. How can you send garbage data? How would any TCP stack know that an application is sending garbage data as opposed to non-garbage data?

    TCPnet is definitely NOT unusual in NOT providing a facility to issue keepalive packets at will from within an application.

Children
  • you're right IB Shy but if I myself have implemented the client side. for example I can send "hello client" and if in client side get such a packet I'd ignore it.

    but if I try to send packet with data included AScomm.net give me an exception.

    (I want to send packet without data to check the reaction of ASComm.net ... but, doesn't matter)

    anyway

    thank guys for your responses

    your posts were very useful for me

    thanks thanks thanks