-
Notifications
You must be signed in to change notification settings - Fork 128
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 new function recv_at_least() to socket stream #224
Conversation
Merge to release/0.7 ? |
net/socket.h
Outdated
@@ -216,6 +216,23 @@ namespace net { | |||
// may block once at most, when there's no data yet in the socket; | |||
virtual ssize_t recv(void *buf, size_t count, int flags = 0) = 0; | |||
virtual ssize_t recv(const struct iovec *iov, int iovcnt, int flags = 0) = 0; | |||
virtual ssize_t recv_mutable(struct iovec *iov, int iovcnt, int flags = 0) { | |||
return recv(iov, iovcnt, flags); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance we need to modify the iovec pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because const iovec*
is a convention, just like readv/preadv/writev/pwritev ...
Obeying the convention can avoid unnecessary errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using another function name is also for obeying the convention, despite C++ has function overloading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I made a mistake. In fact recv/send usually makes a single I/O action that doesn't need to modify the iovec[]. Only recv_at_least needs so.
LGTM |
add new functions recv_at_least() and recv_at_least_mutable() to socket stream
add new functions recv_at_least() and recv_at_least_mutable() to socket stream
to recv at least a number of bytes from socket stream, so as to reduce the # of syscalls