title: Sending data from an Android Activity to PC through ADB
body: <p>Is it possible to send data from an android Activity to adb ? I want to start an activity through ADB and pass it some data, perform an operation, then read the result. 
  What is the best way to do this ?</p>
  
  <p>For example:
  adb.exe shell am start -n com.example/com.example.Adder --ei operand1 10 --ei operand2 20
  This adds 10 + 20 .. and stores the total 30. How do I fetch that value ?</p>
  
  <p>These suggestions from my research are not an option:
  1. write to a file then read it from adb using pull [the phone my not have an SD card, and there is a bug with android 4.3 that means run-as command doesnt work]
  2. opening a socket and sending data through that [I dont want to depend on a network]</p>
  
  <p>UPDATE: 
  so I have been able to do something through adb forward as Chris suggested.
  I first start the adb forward:
  adb forward tcp:10000 tcp:10000;</p>
  
  <p>Then on my android application.. I create a server socket and block at
  serverSocket.accept();
  Then the client connects.. and then you can send data back and forth as you would with TCP/IP socket.</p>
  
  <p>I just have one issue now, which is not documented in ADB; once the forward is setup, the client seems to connect to the server socket even if it is not setup yet on the android side. 
  Why is that the case, is it possible to detect that the serverSocket is not setup yet.. once my clientSocket connects to this "shadow" socket ??</p>