October 4th, 2011, 05:33 PM
[C# / C / C++] Paid project - Send a video file through HTTP
I need a server-side program which accept requests for video files via HTTP from client applications like quicktime or windows media player, and sends back the files.
The media player should correctly receive and play the video.
The requests are like this one:
I tried sending it back the video with a code similar to the following (in C#), but after a while the Send or SendFile calls raise an exception: "connection has been forcibly closed by the remote host", before the file has been completely sent.
GET /media/sample.mp4 HTTP/1.1
User-Agent: AppleCoreMedia/126.96.36.199B367 (iPad; U; CPU OS 3_2 like Mac OS X)
Cookie: __utma=39151136.710240331.1317546773.1317678455.1317758475.7; __utmb=39151188.8.131.527758475; __utmc=39151136; __utmz=39151136.1317546773.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
FileInfo fi = new FileInfo(filePath);
String headers = "HTTP/1.0 200 OK\r\n";
headers += "Content-Type: video/mp4\r\n";
headers += "Content-Length: " + fi.Length + "\r\n\r\n";
client_socket.SendFile(filePath, Encoding.ASCII.GetBytes(headers), null, TransmitFileOptions.UseDefaultWorkerThread );
Strangely enough, if i try to navigate to the video URL (http://184.108.40.206/media/sample.mp4) with a browser, it downloads it completely without errors, but if i play that url from a media player it fails after some data has been received.
If i play the file from local, it works, so i don't think it's a media encoding issue.
If you are able to solve this problem, i'll pay you for a solution to it, of course.
Thanks in advance
Last edited by GordonFreeman; October 5th, 2011 at 04:12 AM.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.