Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gamadeus

macrumors newbie
Original poster
Feb 19, 2011
6
0
I am thinking of a case where a 3rd party app connects over the network and affects changes in a server.
If this app was downloaded to multiple devices, they could all simultaneously run the app and start modifying server-side data, maybe leading to race conditions too.
Could I write some kind of background process for the iphone/ipad that would allow only a single device to run this app at a time in that network? What would it's features be?
Thanks
 
Depending on how the clients interact with the server you are probably best off with some kind of lock.

When one client needs exclusive access, check for the lock, then lock the server, raise a flag/create a file/create a record/..., do your job and then remove the lock.

The details will depend on how the client and server interact.

B
 
Many server side databases are designed to handle multithreaded access safely without data consistency hazards. Read up on databases (locks, atomic commits, and etc.) and choose an appropriate DB.
 
Thanks. That would work except, the server in my case is a black box. It belongs to the same vendor who wrote the app. I was looking for a way to still maintain single access to the server from outside.
Guess I could configure the network, but I'd really prefer something on the client devices side.
If I had a monitor that started at bootup on the device, it would be application agnostic too, so I could use it to maintain access for any app on the device.
 
Actually no.
I do not want to bother about the remote side.
Was seeing if this is possible entirely on the client devices' side with a separate process monitor kind of app. That way if you and I have an iphone and you launch the app, the monitoring app could log usage on my local db and prompt me that the actual app is in use when I also try to launch it from my device.
 
Actually no.
I do not want to bother about the remote side.
Was seeing if this is possible entirely on the client devices' side with a separate process monitor kind of app. That way if you and I have an iphone and you launch the app, the monitoring app could log usage on my local db and prompt me that the actual app is in use when I also try to launch it from my device.

There are no "process monitor" apps on iPhone, unless you jailbreak. Attempting to write one would violate the terms of app store, and would be impossible without a jailbreak on the device anyway, because all apps are isolated from one another by default. This inter-app isolation isn't a user setting; it's enforced for all apps under all circumstances. The only way around it is to jailbreak the phone.

That means you're left with writing an app of your own, that does something more than monitor other apps (processes). Obviously, it's your app, so it can contact any server you write it for, and coordinate with that server using whatever mechanism you write it for. The right way would be to write it to avoid race conditions in the first place. There are several ways of doing that.

If your app on some other iPhone has already coordinated with your server, and told it the app is running on that phone, then it's up to your server to make that information available to your app running on other iPhones. There are several ways of doing that.

If you're just trying to observe other apps and coordinate that info using some server (yours or someone else's), then you can't do that without a jailbreak on each and every phone where the app runs.
 
Thanks. That would work except, the server in my case is a black box. It belongs to the same vendor who wrote the app.

Maybe you should just ask them to implement multi-client access safety then. And why do you suspect that it isn't already implemented that way anyhow ?

You're paying this vendor for this solution, you should not have to write code to make it work. That's what you're paying the vendor for.
 
Good points.
Based on testing with multiple devices, I was able to concurrently control the remote box with the vendor app from each device. So it is apparent that they have not implemented any kind of locking in their implementation.

Interesting to know about Apple policy associated with process monitoring on the phone. Is this the case even for enterprise licenses for intra-company apps?

Based on some looking up earlier, this api link about monitoring arbitrary processes seemed somewhat close to what I was thinking of. Do you see any limitations that I can't spot here?

You know how painful it can be with feature requests directed at vendors and following up on it. It's just like being in queue for healthcare in Canada.
 
One more thought was to have my own app do all the heavy lifting required and then launch this vendor app in question from within, but need to inquire if they publish a URL scheme. Unlikely I think.

This has hit a dead end. Planning to talk this over with them and explore options. Will let you know if I manage something out of this.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.