RTC Forums
April 28, 2024, 10:19:25 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Continuos WriteEx in DataReceived Event  (Read 3230 times)
ISIGest
RTC Expired
*
Posts: 121


« on: May 02, 2015, 10:45:32 AM »

So, I've an RtcHTTPServer and I need to send continuos data to client afer a request.
I've in CheckRequest event accepted the request and I'va call WriteHeader(True);
In OnDataReceived event I've an infinite while that check the buffer and when buffer have data call the "WriteEx" procedure...
All work fine but the client does not receive any data. So, I try to call Flush metod to force write into connection and after this I clear the response (Response.Clear) to re-calculate content length but after first step I got an exception and the connection will be lost.
Can you help me please?

P.S.
I need to make a data flow like a streaming.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: May 02, 2015, 11:17:56 AM »

You are trying to force the components to do something they weren't designed for. When sending large amounts of data, you have to split your code to react on the OnDataReceived and OnDataSent events. Do NOT try to write a continuous loop with WriteEx inside the OnDataReceived events, because that will only flood the memory buffers and won't start sending anything out until the event is finished. If you need an example of a correct Server implementation where large amounts of data are being sent out, check Quick Start Server lessons. Especially the Server Lesson 4, which shows you how to send large files by using the WriteEx method to start the sending process and then use the OnDataSent event to continue, until the whole file is sent.

Best Regards,
Danijel Tkalcec
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #2 on: May 02, 2015, 01:40:26 PM »

All work very very well...Thank you
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 17 queries.