Fixed up and working.
The net_* functions are now usable and I have converted the code to C++.