Re: Does sendmsg only work on AF_UNIX sockets?
Re: Does sendmsg only work on AF_UNIX sockets?
- Subject: Re: Does sendmsg only work on AF_UNIX sockets?
- From: Josh Graessley <email@hidden>
- Date: Thu, 13 Nov 2008 15:47:06 -0800
On Nov 13, 2008, at 3:31 PM, Dave Camp wrote:
<snip>
Unfortunately, my company doesn't want me to go into more detail
about how we are pulling this off on the iPhone, even though it's
completely above board and not violating the SDK license, for fear
of app store rejection. Insert rant about the chilling effect of
random app store rejections here...
I can summarize my problem thusly:
- I have two unrelated processes running on the iPhone.
- I need to move a file of reasonable size (up to 15-20 MB) from one
app to the other. Both apps are consenting in this data exchange, no
hackery going on.
- The iPhone sandboxes apps such that they cannot write to common
areas of the phone or read from other application sandboxes.
- The the sending app has about 5 seconds to get all the data across.
I have code working that sends the data with basic BSD socket code,
but I can't seem to get more than about 2MB/s with plain C socket
code on the phone, whereas the same code gets like 200MB/s in the
simulator. So, in the time I have available to get the data across I
can only get about 10MB transferred. I'd like to get that number up
to 15-20MB.
My first idea was to send an open file descriptor over via a AF_UNIX
socket, but that requires the ability to read/write to a common
location on the filesystem from what I can tell. If the receiving
app was able to read from the file descriptor after the sending
process terminated I would no longer have a time constraint.
Next idea was to send the file descriptor over a local AF_INET
socket, but you can't do that (my original question).
I briefly considered SysV shared memory, but that looks like pure
evil. The docs I've read indicate accidentally leaking a SysV shared
memory space lasts until the next reboot. That would be real bad.
I have not looked at mach ports yet.
Without speculating on whether or not it's against the rules...I don't
know if it's possible or not but if you can register a mach port, you
should be able to look it up from the other process. Even better, if
your file fits entirely in memory (possibly a stretch) and you send it
via a mach message, mach will automatically do some memory map magic
for you.
If you can't use mach, you can use a TCP socket by connecting through
the loopback address. If you're reading the data off the flash to send
over, whether you're using an AF_UNIX socket or an AF_INET socket
connected via loopback, you may end up limited by the read speed of
the flash and not the throughput of the sockets. If you are actually
limited by the throughput of sending data through the socket, sendfile
may give you some performance gain by eliminating one copy.
-josh
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden