Friday, April 13, 2012

Socket programming and C++ serialization

I do have to say that I am not that great at C++. I have a job working as a programmer in C# and its usually my weapon of choice. Tackling the same things as I do with C# in C++ is a bit tough. I'm used to a nice debugger which will tell me anything I need to know about the problem. C++ feels like a step back in programmer friendliness but never the less I can appreciate it for what it provides. Speed and control. C++ is something that I really have to get into. The university unfortunately does a pretty horrendous job at teaching C++. I got all the way through data structures and still struggle with syntax especially when it comes to pointers. I understand the concept very well, but I feel like I don't have enough experience when it comes to them.

As for the code for the last assignment, it did take me a while. I do network programming all the time and I understand how to get a buffer of bytes down a socket and deserialized on the other end pretty well. What killed me for this assignments is pointers and its really my responsibility to go back and relearn a lot of that stuff because like I said, C++ is very powerful. I have to say I am really happy we are doing things the more or less manual way. Really shows how "Advanced" concepts are really pretty simple when you break them all the way down to their basic components.

Sockets! Yes, interesting thing came across the other day. Zombie Yoga now has a statistics gathering server which I wrote the other week. It receives data and parses it into XML for easier read by other devices upon request. Now its time to attatch something cool to the server, like say... a phone or a tablet. As easy as this sounds, this is actually quite annoying. One would assume you just use the java tcp socket (Android) and as long as there is nothing blocking communication, you have a green flag to do post TCP handshakes (verify that your actually who you say you are, or else the server will be busy analyzing packets it doesn't know what to do with) and start passing data to it. Well, no go. First of all, C# is little-endian while Java is big-endian. Ok, too lazy to write a function for that, got Guava. Works, all great. I port this code to Android and it refuses to connect. Nothing. Same code, being executed, nothing. Still have to figure out why I'm having communication problems. Hmmm... got an idea of whats wrong. Ill get back to you guys if I come up with something!

No comments:

Post a Comment