Hi
My program (iphone app) consists of 2 parts - A server socket (sits on port 3490) running on a different thread, and a client to test the server. The server has a video file, and I want to send it to the client upon request. This I do like this:
int fileDesc = open([viewController.filePath UTF8String], O_RDONLY);
if (fileDesc == -1) {
fprintf(stderr, "unable to open '%s': %s\n", [viewController.filePath UTF8String], strerror(errno));
exit(1);
}
off_t offset = 0;
off_t len = 0;
struct sf_hdtr headers;
headers.headers = NULL;
headers.trailers = NULL;
if (sendfile (fileDesc, new_fd, offset, &len, NULL, 0) == -1){
perror("send");
}
Now my client calls this like that:
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://127.0.0.1:3490/"]];
[moviePlayer play];
Now comes the weird part. In the simulator it is not played properly (I can hear only the audio - no video), and on the device it doesn't work at all. It also says: MPMoviePlayerController may not support file of type ''
So then I decieded to investigate and tried to use NSURLConnection to download the file. In the didReceiveResponse method I get that [response expectedContentLength] is -1 and [response suggestedFilename] is 127.0.0.1.dms.
BTW I tried to display a pdf from this server with this method on a UIWebView and it worked.
Thanks
Alex