Giter VIP home page Giter VIP logo

Comments (1)

DAlba-sudo avatar DAlba-sudo commented on May 29, 2024

Just curious, but is this causing undefined behavior for you? Or is this marked a bug because it's not the behavior you think should be used in the std lib?

If I have a stream and call .close(...) on it, I definitely expect it to close the file descriptor (i.e., posix.close(...), but I live in linux mostly and am pretty new to posix so take that as you will.

I wouldn't mind if my underlying socket were to be shutdown on a Stream.close(...), but delegating the responsibility of closing the socket's underlying file descriptor to the user in addition to calling Stream.close(...) seems a bit confusing since I (as an uneducated user) would expect that cleanup to happen in the stream's close function.

I wouldn't expect to do something like:

pub fn main() {
    // assume socketfd has already been initialized 
    var stream = std.net.Stream{ .handle = socketfd };

    // to be honest, I've never actually used the std.net.Stream struct
    // so forgive me if this is not how to idiomatically use it
    defer Stream.close(stream);
    defer posix.close(stream.handle);
}

Just my two cents.

from zig.

Related Issues (20)

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.