I'm writing a VPN application and the socket used for the VPN Connection is handled in my native C code, not in java. How do I use VpnService.protect() on that socket? I noticed that it has a VpnService.protect(int) overload, could I return the int that socket returns from the native code to Java and protect it that way? Example // Native Code int socket; JNIEXPORT jint JNICALL Java_com_my_package_Class_initializeSocket ( JNIEnv *env, jobject jobj ) { socket = socket(AF_INET, SOCK_DGRAM, 0); // . . . Handler other socket preparations return (jint)socket; } // Java Code public native int