saprykin / plibsys

Highly portable C system library: threads and synchronization primitives, sockets (TCP, UDP, SCTP), IPv4 and IPv6, IPC, hash functions (MD5, SHA-1, SHA-2, SHA-3, GOST), binary trees (RB, AVL) and more. Native code performance.
MIT License
672 stars 74 forks source link

Consider supporting TCP loopback fast path on Windows #78

Open merberich-axonvr opened 5 years ago

merberich-axonvr commented 5 years ago

For applications using socket-based IPC, targeting localhost is a common practice. Windows can enable speeding up transfers through localhost by cutting network hardware out of the loop. plibsys doesn't seem to have a way to enable this feature on Windows currently. Perhaps it should to enable higher-performance local TCP comms?

(API reference for enabling this feature. Note that other libraries like ZMQ and libuv do support this feature.)

saprykin commented 5 years ago

@merberich-axonvr, Thank you for pointing out on this API, looks interesting. Actually, you can setup fast loopback with plibsys: get a native socket descriptor using p_socket_get_fd() and then you can apply IOCTL as described in the link you've provided. That is exactly the same way developers from libuv handle it right now (there is no explicitly implemented support for fast loop in libuv). But ZMQ indeed has an option to tune fast loopback when creating a socket.

But I'm considering to extend the API to add a possibility of passing some socket options during the creation. There we can add things like fast path and connection timeout.

merberich-axonvr commented 5 years ago

Oh beautiful, I'll try that, thank you :)