I'm getting PlatformNotSupportedException on Linux when calling TcpClient.ConnectAsync(host, port), with a rather unhelpful message: Sockets on this platform are invalid for use after a failed connection attempt (I'm not trying to reuse a socket)
This is only happening under specific circumstances:
host is a hostname, such as "localhost", AND
- KeepAlive is enabled using
tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true)
Everything works fine if I change either one of these things.
I did a search and came across issues #16263 and #17374, which led to PR dotnet/corefx#16373 - so it seems like you are supposed to be able to connect using a hostname, it's just not working when keep alives are enabled.
I'm getting
PlatformNotSupportedExceptionon Linux when callingTcpClient.ConnectAsync(host, port), with a rather unhelpful message:Sockets on this platform are invalid for use after a failed connection attempt(I'm not trying to reuse a socket)This is only happening under specific circumstances:
hostis a hostname, such as "localhost", ANDtcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true)Everything works fine if I change either one of these things.
I did a search and came across issues #16263 and #17374, which led to PR dotnet/corefx#16373 - so it seems like you are supposed to be able to connect using a hostname, it's just not working when keep alives are enabled.