Let s assume we have a simple internet socket, and it s going to send 10 megabytes (because I want to ignore memory issues) of random data through. Is there any performance difference or a best practice method that one should use for receiving data? The final output data should be represented by a byte[]. Yes I know writing an arbitrary amount of data to memory is bad, and if I was downloading a large file I wouldn t be doing it like this. But for argument s sake let s ignore that and assume it s a smallish amount of data. I also realise that the bottleneck here is probably not the memory management but rather the socket receiving. I just want to know what would be the most efficient method of receiving data.
可以考虑的几种方法是:
在缓冲区满后,在名单和最后名单中增加名单和缓冲。 ToArray() to receive the byte[]
在其完整构造下一代后,向记忆流书写缓冲。 缩略语并读到所有文本,以便获得间接产出。
这样做是否有效率更高/更好的办法?