diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 4a0c045c..776b4c0f 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -290,13 +290,14 @@ scrcpy(const struct scrcpy_options *options) { goto finally_destroy_server; } - socket_t device_socket = server_connect_to(&server); - if (device_socket == INVALID_SOCKET) { + if (!server_connect_to(&server)) { server_stop(&server); ret = false; goto finally_destroy_server; } + socket_t device_socket = server.device_socket; + char device_name[DEVICE_NAME_FIELD_LENGTH]; struct size frame_size; diff --git a/app/src/server.c b/app/src/server.c index c37e0070..0d92cabc 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -219,7 +219,7 @@ server_start(struct server *server, const char *serial, return true; } -socket_t +bool server_connect_to(struct server *server) { if (!server->tunnel_forward) { server->device_socket = net_accept(server->server_socket); @@ -231,7 +231,7 @@ server_connect_to(struct server *server) { } if (server->device_socket == INVALID_SOCKET) { - return INVALID_SOCKET; + return false; } if (!server->tunnel_forward) { @@ -243,7 +243,7 @@ server_connect_to(struct server *server) { disable_tunnel(server); // ignore failure server->tunnel_enabled = false; - return server->device_socket; + return true; } void diff --git a/app/src/server.h b/app/src/server.h index c72dbdd6..4d16fdab 100644 --- a/app/src/server.h +++ b/app/src/server.h @@ -40,7 +40,7 @@ server_start(struct server *server, const char *serial, const char *crop, bool send_frame_meta); // block until the communication with the server is established -socket_t +bool server_connect_to(struct server *server); // disconnect and kill the server process