Re: [twsocket] HttpSvr & send picture stream

2006-11-21 Thread xmedia
Thank you for the code. I have solved the problem. It was caused by other
modules which are not thread safe. The bug ate up HttpSvr's memory space. 

Best regards,
Kyin

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of éric Fleming Bonilha
Sent: Sunday, November 19, 2006 11:58 PM
To: ICS support mailing
Subject: Re: [twsocket] HttpSvr & send picture stream

Hello,

I have developed something similiar to your needs on my application, I have
an HttpSrv that should send an internal stored JPEG to the clients over an
GET request to this JPEG, and it is working just fine, please check this
code, this should be implemented on CommandGET event (ICS 6) (Actually, my
source is written in Delphi, but should be easy to port to C++):

//Create the stream to send the data
StreamImg := TMemoryStream.Create;
try

  //Read the data from my internal JPEG buffer
  Cam.Comunicacao.HTTPImg.ReadImage(StreamImg);

  //Fill the file data and send
  AResponseInfo.ContentType   := 
FHTTP.MIMETable.GetFileMIMEType('.jpg');
  AResponseInfo.ContentLength := StreamImg.Size;
  AResponseInfo.WriteHeader;
  AContext.Connection.IOHandler.Write(StreamImg);

finally
  StreamImg.Free;
end;



- Original Message -
From: "xmedia" <[EMAIL PROTECTED]>
To: "'ICS support mailing'" 
Sent: Sunday, November 19, 2006 1:49 AM
Subject: [twsocket] HttpSvr & send picture stream


> Hello!
>
> I am trying to send a JPEG stream stored in memory to HttpCli. Below is my
> code. It worked well for first few days and then the server (I mean the
> HttpSvr , not the application) just stopped responding to any http request
> until I restart the application.
>
> The cause seems to be related to server load. Because I can expediate the
> process by open a few clients requesting pictures at half second 
> interval -
> which can kill the http server over one night. I have been trying very 
> hard
> to find out what's wrong here with no luck. The source file is similar to
> theHttp Svr demo project - except I replaced the Time portion with JPEG
> stream.
>
>
> Here is what I put in OnGetDocument:
>
>String URL = ((THttpConnection *)Client)->Path;
>if(URL.SubString(1, 6)=="/frame")
>{
>
> Flags  = hgWillSendMySelf;
> frame[0]->Position = 0; //frames[0] is where the jpeg file stream
> stored. If saved to disk, you can get a jpeg file.
> String Header = "HTTP/1.1 200 OK\r\n"
> "Content-Type: image/jpeg\r\n"
> "Content-Length: " + IntToStr(frame[0]->Size)+
> "\r\n\r\n";
>
> TMemoryStream *Stream = new TMemoryStream;
> Stream->Write(Header.data(), Header.Length());
> Stream->CopyFrom(frame[0], 0);
> Stream->Seek(0, 0);
>
> Flags  = hgWillSendMySelf;
> ((TMyHttpConnection *)Client)->DocStream = Stream;
> ((TMyHttpConnection *)Client)->SendStream();
>}
>
> Thanks - kyin
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
> 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] HttpSvr & send picture stream

2006-11-19 Thread Éric Fleming Bonilha
Hello,

I have developed something similiar to your needs on my application, I have 
an HttpSrv that should send an internal stored JPEG to the clients over an 
GET request to this JPEG, and it is working just fine, please check this 
code, this should be implemented on CommandGET event (ICS 6) (Actually, my 
source is written in Delphi, but should be easy to port to C++):

//Create the stream to send the data
StreamImg := TMemoryStream.Create;
try

  //Read the data from my internal JPEG buffer
  Cam.Comunicacao.HTTPImg.ReadImage(StreamImg);

  //Fill the file data and send
  AResponseInfo.ContentType   := 
FHTTP.MIMETable.GetFileMIMEType('.jpg');
  AResponseInfo.ContentLength := StreamImg.Size;
  AResponseInfo.WriteHeader;
  AContext.Connection.IOHandler.Write(StreamImg);

finally
  StreamImg.Free;
end;



- Original Message - 
From: "xmedia" <[EMAIL PROTECTED]>
To: "'ICS support mailing'" 
Sent: Sunday, November 19, 2006 1:49 AM
Subject: [twsocket] HttpSvr & send picture stream


> Hello!
>
> I am trying to send a JPEG stream stored in memory to HttpCli. Below is my
> code. It worked well for first few days and then the server (I mean the
> HttpSvr , not the application) just stopped responding to any http request
> until I restart the application.
>
> The cause seems to be related to server load. Because I can expediate the
> process by open a few clients requesting pictures at half second 
> interval -
> which can kill the http server over one night. I have been trying very 
> hard
> to find out what's wrong here with no luck. The source file is similar to
> theHttp Svr demo project - except I replaced the Time portion with JPEG
> stream.
>
>
> Here is what I put in OnGetDocument:
>
>String URL = ((THttpConnection *)Client)->Path;
>if(URL.SubString(1, 6)=="/frame")
>{
>
> Flags  = hgWillSendMySelf;
> frame[0]->Position = 0; //frames[0] is where the jpeg file stream
> stored. If saved to disk, you can get a jpeg file.
> String Header = "HTTP/1.1 200 OK\r\n"
> "Content-Type: image/jpeg\r\n"
> "Content-Length: " + IntToStr(frame[0]->Size)+
> "\r\n\r\n";
>
> TMemoryStream *Stream = new TMemoryStream;
> Stream->Write(Header.data(), Header.Length());
> Stream->CopyFrom(frame[0], 0);
> Stream->Seek(0, 0);
>
> Flags  = hgWillSendMySelf;
> ((TMyHttpConnection *)Client)->DocStream = Stream;
> ((TMyHttpConnection *)Client)->SendStream();
>}
>
> Thanks - kyin
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
> 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] HttpSvr & send picture stream

2006-11-19 Thread Francois PIETTE
I don't know what is the cause of your problem, but I'm sure you should have 
a look at AnswerStream method in the component.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


- Original Message - 
From: "xmedia" <[EMAIL PROTECTED]>
To: "'ICS support mailing'" 
Sent: Sunday, November 19, 2006 5:49 AM
Subject: [twsocket] HttpSvr & send picture stream


> Hello!
>
> I am trying to send a JPEG stream stored in memory to HttpCli. Below is my
> code. It worked well for first few days and then the server (I mean the
> HttpSvr , not the application) just stopped responding to any http request
> until I restart the application.
>
> The cause seems to be related to server load. Because I can expediate the
> process by open a few clients requesting pictures at half second 
> interval -
> which can kill the http server over one night. I have been trying very 
> hard
> to find out what's wrong here with no luck. The source file is similar to
> theHttp Svr demo project - except I replaced the Time portion with JPEG
> stream.
>
>
> Here is what I put in OnGetDocument:
>
>String URL = ((THttpConnection *)Client)->Path;
>if(URL.SubString(1, 6)=="/frame")
>{
>
> Flags  = hgWillSendMySelf;
> frame[0]->Position = 0; //frames[0] is where the jpeg file stream
> stored. If saved to disk, you can get a jpeg file.
> String Header = "HTTP/1.1 200 OK\r\n"
> "Content-Type: image/jpeg\r\n"
> "Content-Length: " + IntToStr(frame[0]->Size)+
> "\r\n\r\n";
>
> TMemoryStream *Stream = new TMemoryStream;
> Stream->Write(Header.data(), Header.Length());
> Stream->CopyFrom(frame[0], 0);
> Stream->Seek(0, 0);
>
> Flags  = hgWillSendMySelf;
> ((TMyHttpConnection *)Client)->DocStream = Stream;
> ((TMyHttpConnection *)Client)->SendStream();
>}
>
> Thanks - kyin
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be