diff options
Diffstat (limited to 'adb/adb_client.c')
-rw-r--r-- | adb/adb_client.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/adb/adb_client.c b/adb/adb_client.c index 243f0fa..882810a 100644 --- a/adb/adb_client.c +++ b/adb/adb_client.c @@ -16,12 +16,19 @@ static transport_type __adb_transport = kTransportAny; static const char* __adb_serial = NULL; +static int __adb_server_port = DEFAULT_ADB_PORT; + void adb_set_transport(transport_type type, const char* serial) { __adb_transport = type; __adb_serial = serial; } +void adb_set_tcp_specifics(int server_port) +{ + __adb_server_port = server_port; +} + int adb_get_emulator_console_port(void) { const char* serial = __adb_serial; @@ -174,7 +181,7 @@ int _adb_connect(const char *service) } snprintf(tmp, sizeof tmp, "%04x", len); - fd = socket_loopback_client(ADB_PORT, SOCK_STREAM); + fd = socket_loopback_client(__adb_server_port, SOCK_STREAM); if(fd < 0) { strcpy(__adb_error, "cannot connect to daemon"); return -2; @@ -204,9 +211,10 @@ int adb_connect(const char *service) int fd = _adb_connect("host:version"); if(fd == -2) { - fprintf(stdout,"* daemon not running. starting it now *\n"); + fprintf(stdout,"* daemon not running. starting it now on port %d *\n", + __adb_server_port); start_server: - if(launch_server(0)) { + if(launch_server(__adb_server_port)) { fprintf(stderr,"* failed to start daemon *\n"); return -1; } else { @@ -314,5 +322,3 @@ oops: adb_close(fd); return 0; } - - |