Q:

Is it possible to memory map a socket to virtual memory?

I am looking for something similar to memory mapping a file. It would make the virtual memory match the output of the socket byte-to-byte, and would block when no new bytes have been received. Is this possible? 
I am looking specifically for a solution for Rust, but if anyone knows another language that has a feature like this, I might be able to interface with it.

A:

No. It doesn't make sense. A socket is not a random access device, and the length of the mapping is undefined.

A:

When you create a memory mapped file, you specify what file, and what range of data in the file is to be mapped. The area of the file that is mapped is fixed. If the memory mapped file grows (for whatever reason) the new data does not get mapped.
In many systems memory mapped files are implemented the same way as paging. Instead of mapping the virtual memory to a page file, it gets mapped to the file selected by the caller.
What you are asking for does not make sense because you are asking for variable length data to be used with a fixed length data construct.

