views:

13

answers:

0

Im using Erica Sadun's CookBook code to open a socket on the iPad and use a browser on my desktop to connect to the socket, provide a list of file (in this case audio files) and allow the user to downloand them to their desktop.

Erica's code works fine for small audio files, anything over a few MB's gives me a SigPipe Error and crashes the app ...

The key code to send the file is here : As I said all works fine until I try to send a large(ish) file ... any help !!! PLEASE :-)

NSString *mime = [MIMEHelper mimeForExt:[filereq pathExtension]]; if (!mime) { printf("Error recovering mime type.\n"); [self produceError:@"Sorry. This file type is not supported." forFD:fd]; return; }

// Output the file NSString *outcontent = [NSString stringWithFormat:@"HTTP/1.0 200 OK\r\nContent-Type: %@\r\n\r\n", mime]; write (fd, [outcontent UTF8String], [outcontent length]); NSData *data = [NSData dataWithContentsOfFile:filereq]; if (!data) { printf("Error: file not found.\n"); [self produceError:@"File was not found. Please check the requested path and try again." forFD:fd]; return; } printf("Writing %d bytes from file\n", [data length]); write(fd, [data bytes], [data length]); close(fd);

[pool release];