Giter Site home page Giter Site logo

Comments (5)

hirschenberger avatar hirschenberger commented on July 19, 2024

You mean the chance to catch the error of a failed shutdown of the TcpStream? Does this make sense at all? What would be the consequence in the client code?

I agree, that the unwrap must be removed to make the drop not crash the code.

from modbus-rs.

flosse avatar flosse commented on July 19, 2024

What would be the consequence in the client code?

e.g. write a message into the log file and rust continue the application. Let's say there are 100 devices that needs to be controlled. Some of them just needs to connect once an hour. Then I'd be pissed if my whole application crashes just because one connection shutdown panics!

from modbus-rs.

hirschenberger avatar hirschenberger commented on July 19, 2024

Yes that's correct. BTW. I don't know if the TcpStream disconnects automatically after a drop, so we can skip the drop impl at all.
But a close function would be usefull.

from modbus-rs.

flosse avatar flosse commented on July 19, 2024

BTW. I don't know if the TcpStream disconnects automatically after a drop

Yes, the example in https://doc.rust-lang.org/std/net/struct.TcpStream.html tells us that the stream closes after it runs out of scope.

from modbus-rs.

flosse avatar flosse commented on July 19, 2024

...and here https://doc.rust-lang.org/src/std/net/tcp.rs.html#25 we have it too:

The socket will be closed when the value is dropped.

from modbus-rs.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.