I have a file transfer application (big file) and I want to make it so that it is extensible. I use async callback to read messages in messages of 16 kb. Whenever I get a message, I send it to a class that will "deperfire" it and handle it. The format used is simple: (int) command- & gt; (Int) MsgLen- & gt; (String) message
This is just an example. The problem I have is that if I want to read multiple, then what is the best way to handle it? What happens if there are many commands in 1? For example, I came closer to the end and I have only 2 bytes to command the full 4?
I thought about a queue, but it is a pain to remove the bite and replace them. Any better options?
The simplest way is just a Only you need to worry about things, if you get a message, while another process is happening - you get around the operation on the There are more "clever" ways to go about this, but the easiest way to most situations is the easiest way. byte [] array of all outstanding data ( Or similar data structure) always add that array when new data arrives, and then only delete completely received messages.
byte [] array Locking will be required.
Comments
Post a Comment