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.
精彩评论