Re: File access questions
Nathan Sims <[email protected]> Wed, 16 Nov 2011 12:03:29 -0800
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Nov 16, 2011, at 10:49 AM, Kyle Sluder wrote: > On Wed, Nov 16, 2011 at 9:36 AM, Nathan Sims > <[email protected]> wrote: >> The integrity of the data being written/read (from one update to the = next) >> isn't critical (representing very small changes in temperature), so = flock() >> looks like it should be sufficient if all processes cooperate. >=20 > In that case, why use a file at all? It sounds like you've got one > daemon that reports the temperature and N clients on the same machine > that poll for the temperature. Would another IPC mechanism be more > appropriate, like perhaps a Unix domain socket? Wow, I didn't know about Unix domain sockets, but this seems to be a = perfect fit. I can make the Cocoa process into a mini UDP server on a = known sun_path, and the C processes can get the temp data from it by = sending a request to the same sun_path and reading the response packet, = all without connecting. That should be a little more elegant than using = files. Thanks!