Hi all,

I have a web server on my system with interrupt.

My web server work fine ( OPEN, LISTEN, RECV and SEND ).
My browser can connect to my web server and then recovered all the files in my page with the header Keep-Alive.
I have timeout about 400ms between each files.
But when I want to disconnect my peer ( Send CR_DISCON ) at end of timeout because another peer can connect to my web server, I have to wait about 8 seconds before receiving the interruption.
If I try to refresh my page before, I must wait before receive files ( wait disconnection and connection again )

Anybody have an idea for direct disconnection after I have send my command ?

Thank you

You do not have to wait. DISCON sends special packet to the remote network device that server terminates the connection. Server is a master here, thus after this DISCON packet is sent, server can close the connection and set itself to wait for another connection.
You try to do everything properly from your standpoint, waiting for the confirmation of the remote device disconnecting. In general what may happen is that remote device having these 8 seconds of timeout in its TCP protocol engine, and checks incoming packets with this frequency. Thus after 8 seconds elapses it sees DISCON packet and sends confirmation packet to the server. But server actually does not need it.
The one thing which I am curious about is if you do this way - disconnect, then immediately close and set into listening mode - and in 8 seconds remote peer awakes with DISCON confirm packet, will W5100 raise the interrupt? And you can easily check it. I do not think it will be a problem because W5100 will discard the packet as connection is closed.

Thank for your reply Eugeny.

It’s work fine !

I send the disconnect command and immediately, I re-create my server and I go to listen mode.
Effectively, when I do this, I don’t have disconnect interrupt but I don’t need it.

Thank you again.

HI everybody,
I am working at the ssame Problem, but I am not so deeply used to the W5100. What procedure do yo recommend? First if the S0SR goes to CLOSE_WAIT, I set the S0CR to CR_DISCONN. Then I wait for the S0SR to go to SOCK_CLOSED state. Could I skip timeout if I see the S0SR goes to SOCK_LAST_ACK, and then set the S0CR to CR_CLOSE?
Thanks a lot