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.
This commit is contained in:
Romain Vimont 2018-03-14 09:28:25 +01:00
parent 0b1e59186f
commit c530d95881

View file

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