USBMuxConnectByPort

From The Apple Wiki

Function that can be used to tunnel TCP connections over USB, useful for SSH and other stuff

//import iTunesMobileDevice.dll or link with MobileDevice.framework

int USBMuxConnectByPort(int connectionID, int iPhone_port_network_byte_order, int* outHandle);

Example code snippet:

//iphone_port - TCP service port to connect to on the iPhone
//target_device - get this from a device callback.. use AMDeviceNotificationSubscribe to register callback.
		int ret = USBMuxConnectByPort(AMDeviceGetConnectionID(target_device), htons(iphone_port), &handle);
		if (ret != ERR_SUCCESS) {
			printf("USBMuxConnectByPort = %x\n", ret);
			goto error_service;
		}
		
		ret = AFCConnectionOpen(handle, 0, &afc_con);
		if (ret != ERR_SUCCESS) {
			printf ( "AFCConnectionOpen = %i\n" , ret );
			goto error_service;
		}
//handle - handle to use for send/recv