Gonna try and break this down....
I have made a DLL for comms between server/client app i've made. It works fine except a minor issue.
I'm using TcpClient & TcpListener to do the talking.
I have a standard format for all of the messages i send back and forth.
I have message types. Just some random ENUM i put together. For exmaple i have: MessageType.Message which
represents a standard text message.
So say i want to send "Hello" and then the MessageType. So end up with a string "Hello8" (lets just say MessageType.Message has a int value of 8
It would be converted to a byte array using Encoding.Ascii.GetBytes("Hello8")
Result array would look like this:
H = 72
e = 101
l = 108
l = 108
o = 111
8 = 56
That would be sent and recieved just fine. But if i sent it twice (lets just say for arguemnts sake, i like to say hello twice.)
If i dont leave a time delay, enough time for the other end to recieve from the buffer, it gets added on and then the other end.
Then the message recieved would be "Hello8Hello8"
Which is annoying. Now i could add a a byte to the array the start so it contains the length of bytes to read. For a single
message or add a termination by on the end of each message which is fine. I i just don't know which is best and if there is a
solution for this already available?
I hope i have made sense.