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?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,398 questions
.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
323 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,279 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,125 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cheong00 3,471 Reputation points
    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