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