开发者

Is it possible to set UdpClient ReceiveBufferSize property in c#?

开发者 https://www.devze.com 2023-01-25 01:19 出处:网络
I want to change开发者_开发知识库 udpclient receivebuffersize in order to prevent buffer overflow when receiving udp packets. is it possible to change it in c#. The actual property is UdpClient.Client

I want to change开发者_开发知识库 udpclient receivebuffersize in order to prevent buffer overflow when receiving udp packets. is it possible to change it in c#. The actual property is UdpClient.Client.ReceiveBufferSize. Do i have to use other method?

Thanks.


You should be able to doing the following:

  UdpClient client = new UdpClient();
  client.Client.ReceiveBufferSize = 4096;


I don't know whether this helps, but it looks like UdpClient allows you to provide your own Socket. Internally, UdpClient creates the Socket with this statement:

new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

In the Connect(), it checks whether Client has already been set and, if so, uses that Socket to connect to.

0

精彩评论

暂无评论...
验证码 换一张
取 消