Hi everyone,
I’ve been working with the NEPacketTunnelProvider
class and came across the cancelTunnelWithError()
method. The documentation mentions its general purpose but doesn’t provide much clarity on how and when it should be called.
From what I’ve gathered in other forum posts, it seems that cancelTunnelWithError()
should be called within my own implementation of the stopTunnel()
method, but I’m not entirely sure if that’s the correct usage or whether there are specific scenarios where this applies.
Here are my specific questions:
- Is it correct to always call
cancelTunnelWithError()
in my implementation ofstopTunnel()
? - Are there specific conditions or scenarios where
cancelTunnelWithError()
is the preferred way to terminate a tunnel session, rather than other termination methods? - What does the system do with the error that I pass to
cancelTunnelWithError()
? Does it have an impact on how the session termination is handled? - Are there best practices or common pitfalls to avoid when using
cancelTunnelWithError()
?
Any insights, examples, or guidance would be greatly appreciated!
Thanks in advance for your help!