Socket.IOControl method is not supported on Linux platform

SUBRAMANIAN Prabhakaran 1 Reputation point
2021-05-01T07:52:50.023+00:00

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?

Developer technologies .NET .NET Runtime
Developer technologies .NET Other
Developer technologies .NET .NET CLI
Developer technologies C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. cheong00 3,486 Reputation points Volunteer Moderator
    2021-05-03T02:19:56.367+00:00

    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).

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.