I have a c# application where I am reading data from the network into a fixed buffer. However, I do not create the fixed buffer. The buffer is passed to me as an unmanaged memory block (IntPtr). The Socket.Receive method only accepts byte[] or ArraySegments of byte to read into.
The easiest method is to just read data into a temp buffer and copy that data into the unmanaged block, but after having done this, the application uses ~25% more cpu just doing memory copies.
Is there any way I can pass the unmanaged block into the Socket Read and avoid doing the extra memcopy?