Make server_connect_to() return a bool
The resulting socket is accessible from the server instance, there is no need to return it. This paves the way to use several sockets in parallel.
This commit is contained in:
parent
6edb1294f0
commit
5a431cdf9b
3 changed files with 7 additions and 6 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue