Socket.BeginSend Using lots of cpu

1

I have an online gaming server and I have 600 online users, but the cpu is a bit high (using 10 ~ 20% of 26GHz) and the profiler says that this line is using many features

Socket.BeginSend(packet, 0, packet.Length, 0, OnSendCompleted, null);

Callback code:

 private void OnSendCompleted(IAsyncResult async)
    {
        try
        {
            if (Socket != null && Socket.Connected && _connected)
                Socket.EndSend(async);
            else
                Disconnect();
        }
        catch (Exception exception)
        {
            HandleDisconnect(exception);
        }
    }
    
asked by anonymous 28.12.2017 / 06:35

1 answer

0

Probably the solution to the problem is to use SocketAsyncEventArgs ( link )

    
28.12.2017 / 07:16