fs2
fs2 copied to clipboard
Support reading from `ReadCursor` / writing to `WriteCursor` via `Socket`
There are some really efficient APIs for this:
- https://man7.org/linux/man-pages/man2/sendfile.2.html
- https://docs.oracle.com/javase/8/docs/api/java/nio/channels/FileChannel.html#transferTo-long-long-java.nio.channels.WritableByteChannel-
- https://docs.oracle.com/javase/8/docs/api/java/nio/channels/FileChannel.html#transferFrom-java.nio.channels.ReadableByteChannel-long-long-
- https://std.in/using-sendfile-with-nodejs/
I'm fairly confident we can add a default implementation to Socket just using the Stream APIs. If so, then this opens the door for more specialized overrides on the actual implementation.
@armanbilge If this issue is still relevant ,can you assign this issue to me ?
I am thinking that in this issue
- we need to create two files SocketReadCursor and SocketWriteCursor which is used to read from the socket and write to socket just like the cursors in file handling.
- use these to override the implementation in platforms-specific files using sendfile syscall where we send the data directly from the file in disk to kernel which increases efficiency. But I am not understanding the idea of read and writecursors through sockets as these are not persistence or static as files , so idea of sequentially reading using offset seems not right to me? Am i going in right direction @armanbilge