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.
Subsystem
Network
Motivation
I am working with Unix domain sockets (client), and using ktor to communicate between processes via the socket. When I switched to testing on Windows, I noticed that when I tried to connect to the socket, it would instantly close. Upon further digging, the difference appears to be in SocketImpl, upon calling channel.connect, Windows (at least my machine) returns false, which brings it into a blocking condition until the connection is connected. However, as part of that block, the selfConnect would return true since both local and remote addresses are not of type InetSocketAddress, which results in the return condition returning true, and thus closing the connection. leading to a connection closed exception
Solution
Since there was a comment which indicated that selfConnect was for TCP over the network, I simply added a check to validate the local and remote are both not InetSocketAddress, which would be the case for Unix sockets.
Note:
TCPSocketTest.testEchoOverUnixSockets was failing without this change on my machine (which I had to dig around to figure out how to switch the runtime JVM version so the test would actually run. Note for anyone in the future, the jvm version is set in JvmConfig.kt, see Test.configureJavaLauncher extension function)