From c530d95881988d6d48d431e335c50286a53181d9 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 14 Mar 2018 09:28:25 +0100 Subject: [PATCH] Immediately close the server socket on the device In "adb forward" mode, close the server socket as soon as the client is connected. Even if unlikely to be useful, it allows to run several instances of scrcpy also in "adb forward" mode. --- .../main/java/com/genymobile/scrcpy/DesktopConnection.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java index 24735f78..d5740c15 100644 --- a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java +++ b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java @@ -36,7 +36,11 @@ public final class DesktopConnection implements Closeable { private static LocalSocket listenAndAccept(String abstractName) throws IOException { LocalServerSocket localServerSocket = new LocalServerSocket(abstractName); - return localServerSocket.accept(); + try { + return localServerSocket.accept(); + } finally { + localServerSocket.close(); + } } public static DesktopConnection open(Device device, boolean tunnelForward) throws IOException {