When a master requests the connection to be closed (lingering is turned off) the modbus simulator does not close the socket.
I am unsure if you are familiar with TCP internals, but to request a close a FIN+ACK packet is sent placing the socket in a half-open state. Normally when this state is detected you would want to close the socket from the other end as well (or in your case linger for a while if lingering is turned on). However after closing the socket from my end your application waits for 100 seconds before closing even when lingering is turned off. In any case, a lingering time of 100 seconds should be considered *extreme* and it is not exactly "normal" tcp behaviour but perhaps there is a reason (emulation wise) for this?
Since our master can only hold one connection active at a time it also takes 100 seconds before it can connect to the next slave which led me to implement a lingering timeout in our network stack. If the remote does not close within a specified time interval the connection is reset (by sending an RST+ACK packet). This will forcefully invalidate the socket, which leads me to the next problem - your application does not detect this condition either. Checking the netstat listing clearly indicates that Windows has completely dropped the connection and that the socket is no longer active, yet your application still lists an active connection.
It seems it is impossible to communicate more than 10 sessions (number of sockets) in 100seconds (1 session/10 seconds) unless you keep the connections always open towards the modbus simulator.
Log in to post a comment.