-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.
Description
Summary
Provide "peek" APIs to std::net
sockets, for example:
UdpSocket.peek()
UdpSocket.peek_from()
TcpStream.peek()
These methods enable socket reads without side-effects. That is, repeated calls to peek()
return identical data. This can be accomplished by providing the POSIX flag MSG_PEEK
to the underlying socket read operations.
Motivation
This is valuable in cases where a user wishes to validate if new data exists in the socket, without consuming that data completely. For example, a user may wish to use peek()
as a method of polling the socket to find out if new messages are available (or to determine the amount of data available), before deferring to another function to do the actual work of reading and parsing the socket's data.
Metadata
Metadata
Assignees
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.