seanpeery / nmodbus

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

WriteCompleted function on ModbusTcpSlave.cs #23

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Close a ModbusTCPSlave after the master has ended the connection.
2.
3.

What is the expected output? What do you see instead?
ModbusTCPSlave should close gracefully.  An IOException is thrown.  The
call to _stream.EndWrite(ar) will generate an IOException if the server had
already forcibly closed the connection.  The line should probably handle
the IOException.  In any event, the code looks like this:

File: ModbusTcpSlave.cs
Lines: 179 to 193
Function: WriteCompleted
internal void WriteCompleted(IAsyncResult ar)
{
    _log.Debug("End write.");
    _stream.EndWrite(ar);

    try
    {
        _stream.BeginRead(_mbapHeader, 0, 6, ReadHeaderCompleted, null);
    }
    catch (IOException)
    {
        _log.Debug("Master has closed Socket connection.");
        RemoveMaster(_endPoint);
    }
}

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by robma...@gmail.com on 13 Dec 2007 at 3:07

GoogleCodeExporter commented 8 years ago
Fixed in version 1.7

Original comment by sja...@gmail.com on 19 May 2008 at 2:02

GoogleCodeExporter commented 8 years ago

Original comment by sja...@gmail.com on 19 May 2008 at 2:02