UDP “Connect”-Speed in C#

后端 未结 2 1004
孤独总比滥情好
孤独总比滥情好 2021-01-21 05:56

I profiled some boilerplate UDP code and the speed was very good for sending only some small amount data (which is my intent).

BUT the \"connect\" method is \"very slow\

2条回答
  •  面向向阳花
    2021-01-21 06:07

    udpClient.Connect sets the default host name and port, so subsequently you can call Send without specifying them. What's taking the time is the name resolution - translating HOSTNAME into an IPAddress.

    If you do it once in Connect, you don't have to do it every time you Send, which is faster.

提交回复
热议问题