fiddyschmitt
Joined 10 years ago
Joined 10 years ago
https://github.com/fiddyschmitt/SimpleKVM
If you only have two computers, you just need one instance of SimpleKVM to switch between the computers.
As others have mentioned, you can use a cheap USB switch if you don't have an in-built KVM.
DDC/CI is quite interesting. Most OEMs seem to implement it just fine. But some (like LG) need special handling.
In the future I will implement a single file to handle both directions.
Arbitration was indeed one of the trickiest bits. Originally I pre-reallocated the full file size (10 MB). Then used an integer at the beginning of the file to signal to the other side that a block was ready. The other side repeatedly read that int, and read the corresponding part of the file. But writing twice (once for the data, once for the int) had a significant performance impact.
In the end, what worked best was not pre-allocating the file. Rather letting the file grow whenever the writer writes to it. The reader knows when data is available by doing a PeekChar() in a tight loop. It's surprisingly fast, and accurately reflects the state of the file.
1. It gracefully supports each side of the tunnel turning on and off.
2. It accepts any number of clients, and forwards them through the tunnel.
3. It recycles the shared file.
The key to high performance as you rightly pointed out was preventing flushing. In the end, what worked best was reducing the number of writes to disk (which is the bottleneck). I did that by buffering 10-50 ms worth of TCP data, coupled with only flushing explicitly (using a large buffer so that neither BinaryWriter or FileStream flush automatically).
https://github.com/fiddyschmitt/SimpleKVM