I'm using Indy 10 in Delphi XE2 to send 'parts' of an image (remote desktop) as-needed. Meaning, the Client will be sending, in bulk, small pieces of an image non-stop for the life of the socket (or as long as image sending is enabled). The amount of parts which are sent vary in size, and depends on activity on the client. I already have a way to only send certain parts of the screen.
To keep things smooth, I've decided to implement a single string buffer to append the data to, while another thread picks up that data and streams it through the socket. So the thread copies/deletes for example 255 characters from the beginning of the string at a time, and sends along what it copied.
Here's the packet format...
<LEFT><DELIM><TOP><DELIM><SIZE_OF_DATA><DELIM><DATA.......>
<DELIM> = Unique deliminator (global constant)
<LEFT> = Integer: Left position of image part
<TOP> = Integer: Top position of image part
<SIZE_OF_DATA> = Integer: String size of remainder data
<DATA> = String: Data of actual image
...and appending this string to the end of an "Out Buffer String". Another thread then reads from this string and sends chunks no larger than <SET_BUFFER_SIZE> (Setting for buffer size, default 255).
I stopped when I realized that maybe this isn't such a good idea to have an outgoing buffer. Shouldn't Indy already do this for me, and all I have to do is immediately send the packet string?
I already have a separate socket to accommodate for commands which turn this image streaming on or off. I just need to know what's the best recommended method to accommodate for this scenario? Should I use a buffer like this or should I just immediately send it? Would it make a difference for how Indy TIdTCPClient handles the large amounts of data? The client side of the socket does not care whether or not the packet got there, so I'm not worried about the server replying to anything the client sends. However it is important that what was sent is received, therefore I cannot use UDP.
JD Solutions
To keep things smooth, I've decided to implement a single string buffer to append the data to, while another thread picks up that data and streams it through the socket. So the thread copies/deletes for example 255 characters from the beginning of the string at a time, and sends along what it copied.
Here's the packet format...
<LEFT><DELIM><TOP><DELIM><SIZE_OF_DATA><DELIM><DATA.......>
<DELIM> = Unique deliminator (global constant)
<LEFT> = Integer: Left position of image part
<TOP> = Integer: Top position of image part
<SIZE_OF_DATA> = Integer: String size of remainder data
<DATA> = String: Data of actual image
...and appending this string to the end of an "Out Buffer String". Another thread then reads from this string and sends chunks no larger than <SET_BUFFER_SIZE> (Setting for buffer size, default 255).
I stopped when I realized that maybe this isn't such a good idea to have an outgoing buffer. Shouldn't Indy already do this for me, and all I have to do is immediately send the packet string?
I already have a separate socket to accommodate for commands which turn this image streaming on or off. I just need to know what's the best recommended method to accommodate for this scenario? Should I use a buffer like this or should I just immediately send it? Would it make a difference for how Indy TIdTCPClient handles the large amounts of data? The client side of the socket does not care whether or not the packet got there, so I'm not worried about the server replying to anything the client sends. However it is important that what was sent is received, therefore I cannot use UDP.
JD Solutions