How to check XPCConnection is REALLY connected

I'm using XPC to do IPC with an agent service.

I use NSXPCConnection initWithMachServiceName to create the connection and active it.

Then I get the agent service remote object proxy with method remoteObjectProxyWithErrorHandler. But when the agent service unloaded, I can also get the remote proxy without any error.

Is there anyway to check XPCConnection really connect to a XPC server?

XPC inherits its on-demand architecture from launchd. I talk about this in some detail in XPC and App-to-App Communication.

In that architecture, XPC services (and launchd job that vend named XPC endpoints) are expected to:

  • Start on demand

  • Be terminated by the system when they’re no longer needed [1]

Ideally an XPC client shouldn’t care about this. So, XPC connections aren’t like TCP connections. You can’t ask whether one is “connected”. Rather, all you can do is send a message and see if that’s handled.

Why does this matter to you?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Historically this used to be based on an idle timer. These days the system use memory pressure to guide this, that is, if memory pressure is high it starts looking for idle processes to terminate.

How to check XPCConnection is REALLY connected
 
 
Q