Hi.
I wanted to send a photo to a server on my laptop via socket. I created an instance of CFSocket, and configured everything. Now, client(my iphone) and server(my laptop) are connected.
But when i send the photo data, it keeps saying that "Operation not permitted". I know it's not allowed to write files outside of Application Home folder. But is socket now allowed in iPhone? I don't think so, as a lot of apps are using it. Does anyone know how to deal with this?
Here I show you a part of my code:
Code:
- (void)sendPhoto:(CGImageRef)image
{
//Get JPEG data
NSData *data = UIImageJPEGRepresentation((UIImage*)image, 1.0);
//Get file descripter
CFSocketNativeHandle fd = CFSocketGetNative(tcpClient);
//Check if it's valid
if (fd < 0)
return;
//Get size
size_t size = [data length];
//Send data
int bytesSent = send(fd,[data bytes],size,MSG_EOR);
//I should check if bytesSent is -1,
//but i'm getting this error every time.
NSLog(@"%s",strerror(errno)); //"Operation not permitted"
}
Thanks.