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.
@@ -36,7 +36,11 @@ public final class DesktopConnection implements Closeable {
private static LocalSocket listenAndAccept(String abstractName) throws IOException {
LocalServerSocket localServerSocket = new LocalServerSocket(abstractName);
+ try {
return localServerSocket.accept();
+ } finally {
+ localServerSocket.close();
+ }
}
public static DesktopConnection open(Device device, boolean tunnelForward) throws IOException {
