Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a predicate to set a timeout while reading an stream #1083

Open
aarroyoc opened this issue Nov 10, 2021 · 1 comment · May be fixed by #1152
Open

Add a predicate to set a timeout while reading an stream #1083

aarroyoc opened this issue Nov 10, 2021 · 1 comment · May be fixed by #1152

Comments

@aarroyoc
Copy link
Sponsor Contributor

It would be nice to have some kind of timeout for reading streams. This would be quite useful to implement the HTTP/1.1 main feature (keep-alive connections).

SWI-Prolog has: set_stream/2 (timeout is an option) and wait_for_input/3, for reference

@triska
Copy link
Contributor

triska commented Dec 2, 2021

For TcpStream, I think this can be accomplished with set_read_timeout, maybe suitable added to src/machine/streams.rs and an additional interface predicate in library(sockets):

https://doc.rust-lang.org/stable/std/net/struct.TcpStream.html#method.set_read_timeout

For a usage example, see also: https://stackoverflow.com/questions/33557375/how-do-i-prevent-tcpstream-from-blocking-on-a-read

It would be interesting whether this is possible also for TlsStream, since TLS is becoming increasingly common.

@aarroyoc aarroyoc linked a pull request Dec 19, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants