Skip to content

Try another port to listen to if the default one fails #951

@rom1v

Description

@rom1v

Currently, the client listens on port 27183 until the device is connected. The port can be customized by -p/--port option: scrcpy -p 1234.

However, if we start 2 devices at the same time, one of them will try to listen on the same port of the other, and fail with bind: Address already in use.

To avoid this annoyance, -p/--port should accept a range:

scrcpy -p 27183:27186
scrcpy -p 27183  # implicitly 27183:27183

On connection, it iterates over the range until it can bind a port.

The default value could be something like 27183:27200, so that in practice starting scrcpy for several devices simultaneously always work.

See #945.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions