From 76954c13c1c8c0203cd80c480edbadb7f9e09d94 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 11 Aug 2012 08:03:52 -0700 Subject: [PATCH] msg/Pipe: document tcp_*() Signed-off-by: Sage Weil --- src/msg/Pipe.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/msg/Pipe.h b/src/msg/Pipe.h index b7fd4c039bd62..d9aeb6ea2c4af 100644 --- a/src/msg/Pipe.h +++ b/src/msg/Pipe.h @@ -238,9 +238,41 @@ class DispatchQueue; ::shutdown(sd, SHUT_RDWR); } + /** + * do a blocking read of len bytes from socket + * + * @param buf buffer to read into + * @param len exact number of bytes to read + * @return negative error code, or the number of bytes (always == len) read. + */ int tcp_read(char *buf, int len); + + /** + * wait for bytes to become available on the socket + * + * @return 0 for success, or -1 on error + */ int tcp_read_wait(); + + /** + * non-blocking read of available bytes on socket + * + * This is expected to be used after tcp_read_wait(), and will return + * an error if there is no data on the socket to consume. + * + * @param buf buffer to read into + * @param len maximum number of bytes to read + * @return bytes read, or -1 on error or when there is no data + */ int tcp_read_nonblocking(char *buf, int len); + + /** + * blocking write of bytes to socket + * + * @param buf buffer + * @param len number of bytes to write + * @return 0 for success, or -1 on error + */ int tcp_write(const char *buf, int len); }; -- 2.39.5