Skip to content

socket.Send() throw a socket exception ErrorCode:95 on linux #28706

Closed

Description

@SCTIT

I'm setting up a linux server,but my application always throw an exception "System.Net.Sockets.SocketException(95): Operation not supported.The same code can run on Windows Server perfectly.
Here is the part of my code :

private void OnClientReceive(IAsyncResult ar)
{
        try
        {
            Socket socket = ar.AsyncState as Socket;
            SocketError error;
            int size = this.Client.EndReceive(ar, out error);
            if (size > 0)
            {
                byte[] SendBuffer = new byte[size];
                Array.Copy(Buffer , SendBuffer, size);
                this.ServerClient.Client.Send(SendBuffer, SocketFlags.Partial);
                if (this.Service.IsStarting)
                    this.Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, this.OnClientReceive, this.Client);
            }
            else
            {
                this.Close();
            }
        }
        catch(Exception ex)
        {
            Console.WriteLine(ex.ToString());
            this.Close();
        }
}

Activity

  1. karelz commented on Feb 17, 2019

    @karelz
    Member

    Which .NET Core version do you use? Can you try latest released version?

  2. transferred this issue fromdotnet/coreon Feb 17, 2019
  3. stephentoub commented on Feb 17, 2019

    @stephentoub
    Member

    SocketFlags.Partial is not supported with Sends on Linux; it's a Windows-specific concept (even on Windows it might result in not supported failures from the OS as it's only supported by some transports). Why are you specifying it? Can you simply replace it with None?

  4. reopened this on Feb 19, 2019
  5. SCTIT commented on Feb 19, 2019

    @SCTIT
    Author

    Thanks karelz and stephentoub, I have fix this problem.

  6. transferred this issue fromdotnet/corefxon Feb 1, 2020
  7. added this to the 3.0 milestone on Feb 1, 2020
  8. ghost locked as resolved and limited conversation to collaborators on Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions