Availability::- use_module(library(socket)).(can be autoloaded)
tcp_fcntl(+Stream, +Action, ?Argument)
Interface to the Unix fcntl() call. Currently only suitable to deal switch stream to non-blocking mode using:
        ...
        tcp_fcntl(Stream, setfl. nonblock),
        ...

As of SWI-Prolog 3.2.4, handling of non-blocking stream is supported. An attempt to read from a non-blocking stream returns -1 (or end_of_file for read/1), but at_end_of_stream/1 fails. On actual end-of-input, at_end_of_stream/1 succeeds.