Moving from a String based approach?

I want to make my networking better. I’m working with the Netty API and I’ve written a Client/Server application that breaks apart a String that’s been sent over the network and figures things out. An example of my Login packet would look like this.

[1]Username@Password

Where [1] is the packet Id, and then the user/pass (all data, really) is split by the character ‘@’


out.build(176, player.getSession())
                .writeByte(recoveryChange, ValueType.C)
                .writeShort(messages, ValueType.A)
                .writeByte(memberWarning ? 1 : 0)
                .writeInt(lastLoginIP, ByteOrder.INVERSE_MIDDLE)
                .writeShort(lastLogin);
        out.sendPacket();

Here is an example of what I’m looking for. Something that creates a packet like such. I’ve been looking and looking, and I have a github for a server project that uses this type of networking, but I don’t understand it. I’m looking more so on tutorials/documentation for this.

DataInputStream, DataOutputStream.

Better: KryoNet

KyroNet is better than Netty?

Could you please provide more information? I can’t find any benchmark comparisons, etc.

The reason I chose Netty was due to the fact I use a C# based client.
I was reading the KyroNet didn’t support C# Clients, as it used a special network layer? Not sure, never got into it.

So you are looking for something that can serialize java objects to a compact binary representation that is also serializable to from C#? I would guess that you either hand-roll the protocol: i.e. on both the java and the C# side know that to read an int you need to read 4 bytes (or whatever). DataInput/OuputStream is reasonably compact and have a well defined byte layout of primitives so that’s a good tip from Riven.

Other options would be to use google protocol buffers https://developers.google.com/protocol-buffers/ and try to find a C# translation for that.
Kryo is a very good serialization framework that is used by KryoNet but I’m not sure how easy that would be to read in C#.

I’m busy with doing exactly this, and I find Kryonet awesome so far. I recommend it without a doubt :slight_smile:

Mike

if your implementation is a serve centric
where each client will keep a connection whit the server, you can chose a standard interchange protocol

for example you can use CORBA or SOAP

this protocols keep you far for the real technical issues connection, serialization, deserialziation
what you have to do in your code is just create the data that will be transfer

there are several implementation for both the protocols in JAVA or C#, and in case you can integate easily also whit other languages if u need in future

I would pick plain-text over CORBA/SOAP any day.

CORBA/SOAP/RMI/RPC would be very poor choices here. Generic object serialization is going to bite you very quickly. Kyro is definitely a good way to go here, if not just encode your pure data encoding isn’t too bad - wrap it up a bit and you’d probably be fine.

Cheers,

Kev

I would use kryonet. I like its api but not Kryo. In a pure java enviroment it is awesome but hard to work with in other languages.

But kryonet supports custom serialization (http://goo.gl/ZMQu5Q). I would recomment to look at bson and http://goo.gl/iLeJJG.

ClaasJG

Whatever you do, DON’T use CORBA. You would be better off stabbing yourself in the face with a blunt axe.

Yes i have used it extensively in the telecoms i once worked at. God i hope they moved on by now.

Seriously what is wrong with plain text. It is much much easier to debug since network inspection tools work out of the box. Performance is almost never needed and even if it is in the future i would always have a plain text fallback/debug mode.