Add a new Socket Stream Protocol - #47
Conversation
1d6247e to
27f4de0
Compare
agnosticdev
left a comment
There was a problem hiding this comment.
A few things, mainly on creating test harness code.
agnosticdev
left a comment
There was a problem hiding this comment.
Everything looks good, it just looks like there are some linux test failures outstanding.
| let harness = UDPLoopbackHarness(basePort: 10840) | ||
| harness.start() | ||
| harness.expectDeliver([0xFF]) | ||
| harness.teardown() |
There was a problem hiding this comment.
Yep, this is exactly what we want, thanks!
f9d3b02 to
471a92d
Compare
8245a76 to
adf0813
Compare
adf0813 to
f7e3928
Compare
The read DispatchSource was armed in setup(), before connect completed. On Linux a spurious readable edge at connect-completion left it permanently silent, stalling all receives. Resume the read source only after connect completes. Also consolidate the read and write sources onto one shared dup'd fd (closed via a refcount once both cancel) to avoid epoll fd-aliasing and the EPOLLFREE abort that fires when a still-registered socket fd is closed. Applied to both SocketStreamProtocol and SocketDatagramProtocol.
6b8ec6c to
66157a7
Compare
agnosticdev
left a comment
There was a problem hiding this comment.
Great, thank you very much @PayasR !
| guard let reference = TCPProtocol().newProtocolInstance(context: context) else { | ||
| throw NetworkError.posix(EINVAL) | ||
| if case .custom(let linkOptions) = stack.link, | ||
| linkOptions.identifier == BridgeDatagramProtocol.identifier |
There was a problem hiding this comment.
A little unusual to be using the BridgeDatagramProtocol for TCP
| } else { | ||
| let socketReference = SocketStreamProtocol.instance(context: context) | ||
| options.setProtocolInstance(socketReference) | ||
| let linkage = OutboundStreamLinkage(reference: socketReference) |
There was a problem hiding this comment.
a lot of this is repeated - it's really about setting the instance and getting the linkage and the rest is the same.
|
|
||
| @_spi(ProtocolProvider) | ||
| @available(Network 0.1.0, *) | ||
| public func parseIPv4(_ string: String) -> IPv4Address? { |
There was a problem hiding this comment.
these can be replaced now that https://github.com/apple/swift-network-evolution/pull/44/changes went in
This lets us use Kernel TCP socket streams for when userspace TCP isn't available.