I have video data and am generating new frames for many clients regularly. I'm getting the frames from the library as an IntPtr and an int representing the size of the byte array. Currently I'm turning that into a "Memory" and sending it over a NetworkStream achieving zero-copying of the rather large buffer once I have it.
I would like to try to do the same thing using SocketAsyncEventArgs to see if it performs better and try those UserTokens for multiple clients. However, I can't figure out how to tell SocketAsyncEventArgs to send a chunk of memory pointed to by an IntPtr with a int representing a known size while maintaining zero-copy. Seems like some clever Marshalling or "MemoryMarshal" should do the trick but I'm not seeing it.
Do you see a way to accomplish this?