c# - Flush the buffer after receiving packets -


this question has answer here:

i using below code receiving tcp packets tool.

while(socket.connected) {   var buffer = new byte[4096];   int receivelength = socket.receive(buffer);   if (receivelength != 0)   {       byte[] response= new byte[4096];      processpacketdata(buffer, out response);       socket.send(resposne);   } //sleep(100); } 

when using code, problem facing is,for socket.receive() function buffer doesn't getting flushed. every time, when calling socket.receive(buffer), new data packets getting appended old packets contained in buffer. want avoid situation. there solution this?

receive not receive packets. receives amount of bytes greater 0 bytes. use return value receivelength find out how received , process amount.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -