TCPNET: I can't tcp_close() sockets with IE7

Hi all,

I am implementing a web server using the RL TCP/IP stack. I'm using a web server from Allegro (RomPager), as opposed to the Keil HTTP server, because I required SSL/TSL.

I've got to the stage where the web server works through the Keil TCP/IP stack, and even SSL works.

When the web server wants to close a connection that exists over a socket, I make use of the tcp_close() function. From reading the documentation and from reading other posts and FAQs from this site, I understand fully that the procedure is as follows:

1. Call tcp_close(). It should return __TRUE.

2. Allow time for the listener socket callback function to be called, with the value TCP_EVT_CLOSE.

3. Then, ensure the socket has definitely finished closing by calling tcp_get_state, and ensuring the result is either TCP_STATE_CLOSED or TCP_STATE_LISTEN.

Here's the problem: If the browser is Internet Explorer 7, a call to tcp_close() NEVER results in a TCP_EVT_CLOSE event at the callback function. If my memory serves me right, a call to tcp_get_state always results in TCP_STATE_FINW2. After a few seconds though (maybe 10 or 20 seconds), Internet Explorer 7 seems to abort the connection. Once IE7 has aborted the connection, then the socket definitely does return to TCP_STATE_LISTEN.

If I use Firefox, the socket DOES close properly. I call tcp_close(), and the callback function is quickly called with a TCP_EVT_CLOSE event, and my socket becomes a listener again immediately.

I am new to network programming and I have not yet used a network sniffer to try to see what's going on. But that's what I'm going to try to do next. If anyone has any suggestions in the meantime about this, I would be extremely grateful for suggestions.

Regards

Trevor

Parents
  • I've now downloaded Wireshark and I can see exactly what's going on.

    First of all, a useful reference: kb.iu.edu/.../ajmi.html

    With Internet Explorer 7, I see:

    Keil Stack (server) -> IE7 (client) [FIN,ACK]
    IE7 -> Keil Stack [ACK]

    ...and that's it: IE7 does not send a [FIN,ACK] back to the server. So in effect, IE7 allows the connection to remain half closed. And this results in the socket sitting in the TCP_STATE_FINW2 (FIN-WAIT-2) state.

    With Firefox, I get the full [FIN,ACK]..[ACK] happening in both directions. Firefox properly closes its side of the connection immediately, too.

    So, I dunno - maybe I just need to put a mechanism into the code that detects when the socket has been sat in FIN-WAIT-2 for far too long and, if so, invokes a tcp_abort.

    Trev

Reply
  • I've now downloaded Wireshark and I can see exactly what's going on.

    First of all, a useful reference: kb.iu.edu/.../ajmi.html

    With Internet Explorer 7, I see:

    Keil Stack (server) -> IE7 (client) [FIN,ACK]
    IE7 -> Keil Stack [ACK]

    ...and that's it: IE7 does not send a [FIN,ACK] back to the server. So in effect, IE7 allows the connection to remain half closed. And this results in the socket sitting in the TCP_STATE_FINW2 (FIN-WAIT-2) state.

    With Firefox, I get the full [FIN,ACK]..[ACK] happening in both directions. Firefox properly closes its side of the connection immediately, too.

    So, I dunno - maybe I just need to put a mechanism into the code that detects when the socket has been sat in FIN-WAIT-2 for far too long and, if so, invokes a tcp_abort.

    Trev

Children
More questions in this forum