Difference between revisions of "USBMuxConnectByPort"

From The iPhone Wiki
Jump to: navigation, search
Line 1: Line 1:
 
Function that can be used to tunnel TCP connections over USB, useful for SSH and other stuff
 
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
 
//import iTunesMobileDevice.dll or link with MobileDevice.framework
   

Revision as of 03:48, 16 May 2010

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