seanpeery / nmodbus

Automatically exported from code.google.com/p/nmodbus
0 stars 0 forks source link

ModbusTcpSlave does not close open connections on Dispose #51

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create and start a ModbusTcpSlave instance
2. Fire a ModbusMaster or other client
3. Call the Dispose method on the instance

What is the expected output? What do you see instead?
The connection to the client application (modbus master) should be closed.

What version of the product are you using? On what operating system?
3.5_1.11.0.0 on Windows 7

Please provide any additional information below.
An additional method should be provided for closing the underlying sockets 
/ connections with all Masters, because manually closing the TcpClients in 
the Masters collection causes the throwing of exceptions.

Original issue reported on code.google.com by stroggy...@gmail.com on 1 Dec 2009 at 2:18

GoogleCodeExporter commented 8 years ago
I suggest that if the clients are reachable by the ModbusTcpSlave.Master 
accessor 
method we can close all the clients manually:
foreach (TcpClient client in modbusSlave.Masters) {
    client.Close ();
}

but the library needs to catch the Exceptions and not to throw them
(see ModbusMasterTcpConnection.CatchExceptionAndRemoveMasterEndPoint)

Original comment by str...@gmail.com on 18 Feb 2010 at 6:55