   Is there a better way to send data ?
  Hi.First of all, i'm not really new to game programmation or networking but the only way i know (and i can imagine) to send data is to seperate each part with a unique character.Well, something like this "PacketName/FirstData/SecondData/..." and so on.I was wondering if there was a better/faster way to do it ?Do a SubStr to get only the PacketName and cut it with the number of bytes the Part of data should take would be faster ?Thanks for helping.   
  Binary serialisation would be more efficient over the network. So, the packet name would be an encoded identifier in 1,2 or more bytes (depending on the total number of packet types available).It depends on the game though. If it was a turn based game then it might not matter. For low latency games, binary protocols are generally used.   ;  If the length of each part is known to both sides then it's trivial to simply read however much is needed for each part in order. For example, if I give you 4 bytes with two chars and a short in there, it's easy for you to simply read the first byte, then the second byte, then the last two bytes together. It's a little more complicated if you're trying to, say, send a list of unknown size. Either padding it out to a fixed size (common for short strings) or putting the length as the first byte (or more if the list can be long) is common. Of course, using a "unique character" for that as you have been is also good; it's intuitive to define the end of a string to be a null character and similarly this is appropriate for some other lists, too.I hope that helps.   ;  That is basically the way to do it, send a unique char, data, unique char, data.;Binary Writer/Reader for Bit-based packets. Pretty standard problem. On a related note I'm still trying not to post in that "Using structs for network packets" since I hate the struct way. >_>   ;  In general, sending network data over a TCP stream is similar to writing data to a file.If you can figure out how to write data to a file such that it can be read in again piece by piece (as a stream), then the same mecanism can probably be used for a TCP connection.;  HEY! Whats wrong with using structs? :P The more I use it the more I find it better than just randomly adding data to a byte array. Your saving space because you don't need to specify in your packet what the next piece of data is or how long it is.Other code I've seen is (for a general example)Dim PACKET as clsNetworkPacketPACKET.Add(integer1)PACKET.Add(integer2)PACKET.Add(byte1)PACKET.Add(blahblah)This is the way I did it for a long time as well. The problem with that, and that I also ran into, is now when your reading the packet on the other side, you need to read the data in the same order as you added it. Then if it gets changed later, you need to change it on both ends. Or you need to delineate each piece of data using a special character, but then your using more space in the packet.With the structures, it's literally more structured :) Your working with the exact same structure on both sides. It's defined ahead of time and easily changeable. If you add more data to the structure you don't have to worry about making sure to read it or write it a certain way. You have a useful name for all the properties instead of just grabbing so many bytes and making it the data type you need.Also since your using a defined structure the IDE shows you all the available properties for the packet. As well as if you comment it correctly you can have comments for the packet and it's properties show up right in the IDE...Honestly though I would like to hear your dislike for the structs, in my thread of course. Didn't mean to thread-jack but it's still relevant :)To the OP, use structs :)   ;  Writing a function that does only reads, and then a matching function that does only writes, is a bad idea, because they will diverge and you'll get bugs.Instead, you want to write a function that "visits" the members of the data structure in order. On one side, you can pass in a "writer" visitor, and on the other, a "reader" visitor. That way, the writing and reading will happen in the same order. The function calling the visitors can use System.Reflection to figure out what there is to pack/unpack.The main draw-back is that getters and setters that go through Reflection may generate garbage through boxing on each access.   