plcpeople / nodeS7

Node.JS library for communication to Siemens S7 PLCs
MIT License
363 stars 122 forks source link

Fixes #80 - prevents write after end #81

Closed gfcittolin closed 5 years ago

gfcittolin commented 5 years ago

Fix proposal for #80

When the 'end' or 'close' events are emitted, we always call connectionReset(), that in turns set self.isoConnectionState = 0. Therefore, if we check for the required self.isoConnectionState of 2 before proceeding, we should avoid calling write on an already closed stream.

That was the only "unchecked" call of isoclient.write(). There may be although other points on the code where the connection gets reset by us and we don't update the self.isoConnectionState