Search code examples
iossocketstcpvpntunnel

Is there a way to get the socket descriptor of the started VPN Tunnel on iPhone so that I could use it in a C++ library


In the simpleTunnel sample app provided by apple, the container app and the packet tunnel provider use IPC for communication.

Whenever connect toggle button is enabled startVPNTunnel() API will be called and the OS starts the packet tunnel provider which in turn calls the overrided method startTunnelWithOptions(). This is where we start our connection to the VPN server. startTunnelWithOptions in turn calls startTunnel which calls createTCPConnectionToEndpoint (connection = provider.createTCPConnectionToEndpoint(endpoint, enableTLS:false, TLSParameters:nil, delegate:nil))

How do we get the socket descriptor from this connection (so that I could use it in another C++ library that sends SSL and other custom messages) ? (connnection is an instance of the class NWTCPConnection, but NWTCPConnection doesn't seem to contain the socket descriptor)


Solution

  • Not sure I understood you, but if you are looking for the socket's file descriptor - you can't get it.