ilkinimanov
ilkinimanov

Reputation: 43

$ADB_SERVER_SOCKET

I have a question. I was learning how to connect to android emulator from wsl-2. I saw $ADB_SERVER_SOCKET variable when looking for a solve way for the problem. I can’t find any information about the variable. Can anyone share a official source about the variable?

Upvotes: 2

Views: 2501

Answers (1)

Robert
Robert

Reputation: 42754

adb has two parts:

  1. adb client - the command-line adb executable you use
  2. adb-server - this component is the one talking to your devices. If you execute adb client and the server is not running then it starts it.

Both communicate to each other using TCP. Usually both parts are running on the same computer and even on the same user account.

By using the variable $ADB_SERVER_SOCKET you can advice the adb client to connect to an adb-server running somewhere else. As WSL2 is a virtual environment separated from your regular Windows you can use it to advice e.g. adb client inside WSL2 to communicate with adb-server on your Windows machine.

export ADB_SERVER_SOCKET=tcp:$WSL_HOST_IP:5037

Your WSL_HOST_IP can be found in /etc/resolv.conf in the nameserver entry1.

Upvotes: 4

Related Questions