title: How can I set the buffer size for the underneath Socket UDP? C#
body: <p>As we know for UDP receive, we use Socket.ReceiveFrom or UdpClient.receive</p>
  
  <p>Socket.ReceiveFrom accept a byte array from you to put the udp data in.</p>
  
  <p>UdpClient.receive returns directly a byte array where the data is</p>
  
  <p>My question is that How to set the buffer size inside Socket. I think the OS maintains its own buffer for receive UDP data, right? for e.g., if a udp packet is sent to my machine, the OS will put it to a buffer and wait us to Socket.ReceiveFrom or UdpClient.receive, right?</p>
  
  <p>How can I change the size of that internal buffer?</p>
  
  <p>I have tried Socket.ReceiveBuffSize, it has no effect at all for UDP, and it clearly said that it is for TCP window. Also I have done a lot of experiments which proves Socket.ReceiveBufferSize is NOT for UDP.</p>
  
  <p>Can anyone share some insights for UDP internal buffer???</p>
  
  <p>Thanks</p>
  
  <p>I have seen some posts here, for e.g.,</p>
  
  <p><a href="http://social.msdn.microsoft.com/Forums/en-US/ncl/thread/c80ad765-b10f-4bca-917e-2959c9eb102a" rel="noreferrer">http://social.msdn.microsoft.com/Forums/en-US/ncl/thread/c80ad765-b10f-4bca-917e-2959c9eb102a</a></p>
  
  <p>Dave said that Socket.ReceiveBufferSize can set the internal buffer for UDP. I disagree.</p>
  
  <p>The experiment I did is like this:</p>
  
  <p>27 hosts send a 10KB udp packet to me within a LAN at the same time (at least almost). I have a while-loop to handle each of the packet. For each packet, I create a thread a handle it. I used UdpClient or Socket to receive the packets.</p>
  
  <p>I lost about 50% of the packets. I think it is a burst of the UDP sending and I can't handle all of them in time.</p>
  
  <p>This is why I want to increase the buffer size for UDP. say, if I change the buffer size to 1MB, then 27 * 10KB = 270KB data can be accepted in the buffer, right?</p>
  
  <p>I tried changing Socket.ReceiveBufferSize to many many values, and it just does not have effects at all.</p>
  
  <p>Any one can help?</p>