How to disconnect and reconnect again?
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: How to disconnect and reconnect again?
by epppp ·
Hi, I found the problem. There was a mistake in my code. But anyway what happens If there is a established connection between two module and we call close() function without calling disconnect() .
RE: RE: How to disconnect and reconnect again?
by acpie360 ·
The disconnect() will do the FIN/ACK dance so that both sides can close sockets gracefully, assuming the connection has been maintained. Otherwise, the disconnect() will perform close() on timeout. Here is the source code from the ioLibrary -
RE: RE: How to disconnect and reconnect again?
by Eugeny ·
Nothing happens if you perform CLOSE, and it can be good, as well as bad. It is bad in the cases when remote device will still think that your device has something to say, and keep its socket open. That socket of remote device of course should be closed with time out, but it may happen if device has limited number of sockets it will get full stack open, and will not be able to accept more connections.
So generally it is a good practice to call DISCON before you call CLOSE in case W5500 socket is in ESTABLISHED state. Though you may not need to wait for DISCON to get socket to the closed state, but just doing DISCON and then after disconnect command finishes doing CLOSE. If remote device will want to say something, it will get RST from the W5500.
RE: How to disconnect and reconnect again?
by ImHang ·
Hi, I had a problem about the situation that you just talked about. How can I DISCON in CLOSED or INIT state? Because when internet has problem and disconnect TCP client, but in remote device still keep its socket open so that device cannot connect to that socket. So how do I reclose socket from client side without waiting for timeout?
RE: How to disconnect and reconnect again?
by irina WIZnet ·
I think you have to read the value of Sn_SR and the status of W5500 is sending FIN packet or was sent FIN packet.
I think you can also know the TCP Server status.
Generally I’m using the wireshark(packet capture program) when used for test and you can also see the packet using program.
If it is possible, please check the status of W5500 or TCP Server and let me know.
RE: How to disconnect and reconnect again?
by Eugeny ·
Both operations are invalid from the internal W5500 network stack standpoint. If socket is in closed or initialized state, result of DISCON command is neither defined nor guaranteed. Look here at page 29, W5500 is the same. There’s no place for DISCON command other than in ESTABLISHED or SOCK_CLOSE_WAIT socket states.
The remote device must have timeout, and it will close its hung socket after some time (driven by this timeout or by probing).
You must use different local port number within W5500 for TCP communication creating new connection and continuing communication through this new connection.
If remote server has reset the current connection, or W5500, after prolonged interval of connection interruptoin will reset current connection, there’s no way to resume it, and you must make new one.
The flow is the folllowing: