C# UDP packetloss though all packets arrive (WireShark)

前端 未结 1 497
走了就别回头了
走了就别回头了 2021-01-13 17:14

As the title says I have a problem with UDP in C#. I\'m trying to build a library for the rcon protocol of the game DayZ.

My problem is that I dont receive every pac

1条回答
  •  南笙
    南笙 (楼主)
    2021-01-13 18:04

    This is usually because you are not consuming your datagrams fast enough, so in-kernel socket buffer gets full and the network stack starts dropping newly arriving packets. Some points:

    • Increase the receive buffer on the socket,
    • Don't acquire locks on every iteration - read as much as you can, then put data into the queue,
    • Consider non-blocking approach instead of threads.

    0 讨论(0)
提交回复
热议问题