net: support sync connect for BoundSocket#64375
Open
guybedford wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
When a net.Socket is constructed from a net.BoundSocket, support synchronous connect(). Signed-off-by: Guy Bedford <guybedford@gmail.com>
f731ea6 to
a607d87
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64375 +/- ##
==========================================
+ Coverage 90.23% 90.24% +0.01%
==========================================
Files 741 741
Lines 241194 241210 +16
Branches 45432 45434 +2
==========================================
+ Hits 217640 217692 +52
+ Misses 15129 15085 -44
- Partials 8425 8433 +8
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows obtaining
socket.localAddress/socket.localPortsynchronously, immediately aftersocket.connect(), when the socket is constructed from anet.BoundSocket.#63951 added
bind2()-style early binding fornet.Socket, enabling synchronous local port reservation. This extends the same idea toconnect(): the kernel resolves the concrete source address (autobind + source selection) inside theconnect(2)syscall itself (without blocking), so a bound socket connecting to an IP literal can provide that address immediately matching POSIX/libuv semantics.net.Socket.connect()normally defersconnect(2)to a later tick due to the DNS lookup step, which doesn't exist for anet.BoundSocket, so connect(2) can be issued synchronously.Tests are included for a concrete source resolved via
localAddress/localPortsynchronously afterconnect(), as well as a synchronous throw.