zhboner / realm

A network relay tool
MIT License
1.54k stars 285 forks source link

Does bidi_copy_buf can be used in any os #90

Closed hzxuzhonghu closed 1 year ago

hzxuzhonghu commented 1 year ago

If not how could write code that can be run on any os?

zephyrchien commented 1 year ago

It depends on the buffer you provide. Box<[u8]> or other types which impl AsMut<[u8]>, and the associated read/write syscall can be found on any platform. However unix pipe is for unix, and splice is a linux-specific syscall.

hzxuzhonghu commented 1 year ago

How about bidi_zero_copy, I used it to splice between two socket in a proxy

zephyrchien commented 1 year ago

It is a one-line wrapper of copybuf. Please look into the source code.

hzxuzhonghu commented 1 year ago

I am new to rust, i suspect it is not cross-platform, just to confirm here

zephyrchien commented 1 year ago

bidi-zero-copy is for linux only. You can use conditional compilation to fallback to bidi-copy on other platforms.

zephyrchien commented 1 year ago

https://github.com/zhboner/realm/blob/master/realm_core/src/tcp/plain.rs

hzxuzhonghu commented 1 year ago

Thanks for the clarification here