How to use net.Stream in non-blocked mode

Until now I have been using net.Stream in synchronous mode.

Now I need to change the communication mode to non-blocking using posix.poll.

Comment in the net.zig states:

    /// TODO in evented I/O mode, this implementation incorrectly uses the event loop's
    /// file system thread instead of non-blocking. It needs to be reworked to properly
    /// use non-blocking I/O.

Does this mean that I cant use net.Stream in non-blocking mode?

Comment is outdated, there is no event loop to use as async was removed.

you can use it in non-blocking, you will have to do all the work for whatever async IO OS interface you use, or use a library

if you follow the source you can see its just scaffolding for syscalls, or dyn lib for windows

1 Like

Implementation of Non-blocked net.Stream based client

Magic - Set socket non-blocked mode - stollen from std

Regarding Windows - see Using std.os.poll on windows causes undefined reference error