diff options
author | ajs <ajs> | 2005-02-16 20:35:47 +0000 |
---|---|---|
committer | ajs <ajs> | 2005-02-16 20:35:47 +0000 |
commit | 262feb1ad0838bb585955b6ada5acbe106dbc9bf (patch) | |
tree | 392f66d5d71bcfdd87e5db32e89325ed9ef06c44 /lib/stream.h | |
parent | 42218e71256cb86b5078c99c931030c7b0ce9bab (diff) |
2005-02-16 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* stream.h: Declare new function stream_read_try suitable for use
with non-blocking file descriptors. Indicate that stream_read
and stream_read_unblock are deprecated.
* stream.c: (stream_read_try) New function for use with non-blocking
I/O.
(stream_recvmsg) Should return -1 if the stream is too small to
contain the data.
Diffstat (limited to 'lib/stream.h')
-rw-r--r-- | lib/stream.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/stream.h b/lib/stream.h index fe45a4f5..54a16740 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -165,8 +165,25 @@ u_int32_t stream_get_ipv4 (struct stream *); #undef stream_read #undef stream_write + +/* Deprecated: assumes blocking I/O. Will be removed. + Use stream_read_try instead. */ int stream_read (struct stream *, int, size_t); + +/* Deprecated: all file descriptors should already be non-blocking. + Will be removed. Use stream_read_try instead. */ int stream_read_unblock (struct stream *, int, size_t); + +/* Read up to size bytes into the stream. + Return code: + >0: number of bytes read + 0: end-of-file + -1: fatal error + -2: transient error, should retry later (i.e. EAGAIN or EINTR) + This is suitable for use with non-blocking file descriptors. + */ +extern ssize_t stream_read_try(struct stream *s, int fd, size_t size); + int stream_recvmsg (struct stream *s, int fd, struct msghdr *, int flags, size_t size); int stream_write (struct stream *, u_char *, size_t); |