Rewrite from Java to C++

Okay, so my server is currently running on Java and makes use of DataOutputStream and DataInputStream. And whilst I’m on a rewrite, I need to wrap those into C++.

Which I thought might be a tad difficult…

It turns out that Linux automatically handles UTF-8 strings out of the box, so sending and receiving string is of no consequence. Which was one of my main worries before I looked into everything else which slowed down the transition. Java’s DataOutputStream writes it UTF-16 strings as UTF-8 strings over the wire. That’s that problem solved.

The other problem was wrapping the socket connection. Sorted. Easily done by returning the error status on every call and handling the active status of the socket.

The last problem was wrapping the Java functions for sending a Long, Int, Byte, String, etc… These need to be in network byte order, which is not little endian. I’m just going through that now.

Oh yeah, encryption using a Cryptographic Secure Pseudo Random Number Generator. Done and implemented to match perfectly the Java version… For now.

So hopefully soon, I’ll be able to test run this wrapper ready for a production run.

Leave a Reply

Your email address will not be published. Required fields are marked *