I'm running into a problem calling GetSocketOption in C# using .net core 5.0 on Linux.
Calling:
_socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger);
This throws an exception "Operation not supported". Ok, so that option isn't support in the env I'm using it in.
The problem is that the exception closes (disconnects) the socket. The _socket.Connected
property is true before this statement and false after it. Is there a way to check this in C# without risking the generation of a socket disconnect? Is there a "safe" way to check socket options?
While writing OS specific code for this is perhaps pragmatic I'm looking for a way to handle this in a non-OS specific way, that is after all one of the draws of .net core.
Update: FWIW, I posted this as an issue and it can be tracked here: GetSocketOption/SetSocketOption should not close underlying socket