question

SUBRAMANIANPrabhakaran-8794 avatar image
0 Votes"
SUBRAMANIANPrabhakaran-8794 asked cheong00 answered

Socket.IOControl method is not supported on Linux platform

Hi,
I have one .Net Core 3.1 console application in which Socket.IOControl method used.
When running at linux server(RedHat),it is getting error at runtime.
Please find the below code,

Code:

Socket m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
m_Socket.Bind(new IPEndPoint(m_OriginAddressIP, m_iPort));
m_Socket.IOControl((IOControlCode)SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 1 }, null);


Error:
"Socket.IOControl handles Windows specific control codes and not supported on linux platform"

How to solve this error in linux?


dotnet-csharpdotnet-runtimedotnet-clidotnet-ad
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cheong00 avatar image
0 Votes"
cheong00 answered

There is no corresponding option in Linux to tell the network connection report "connection reset" or not. Maybe the closest thing you can do is to catch SocketException. I'm not sure if .NET Core runtime will translate the error number in Linux to error code because the error code between TCP and UDP connection in Linux is different (Seems "Connection reset" is -18 for UDP and 104 for TCP).


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.