title: how to use adb port forwarding?
body: <p>I am creating a debugging plugin in for Android Studio, and this will start a server and listen to a port. The device(mobile with adb deamon running) connected via USB. </p>
  
  <p>And my application will send some files, requests, logs simply data to a port. This is my concept. </p>
  
  <p>So I want to send it through USB. While some digging I found <em>ADB port forwarding/reversing</em> is the answer for this. But I didn't understand the whole concept of port forwarding using adb.</p>
  
  <ol>
  <li><p>Am I want to start <code>ServerSocket</code> on both developing machine and mobile?</p></li>
  <li><p>If So, I started <code>ServerSocket: on port 8080</code> and device <code>ServerSocket: on 9090</code> then execute <code>adb forward tcp:8080 tcp:9090</code> will be diverted to <code>8080</code> that is on developing machine?</p></li>
  <li><p>How they forward or redirect to machine port?</p></li>
  <li><p>How to execute adb commands from java code?</p></li>
  </ol>
  
  <p>The ultimate aim is I want to communicate with my application/library from phone to developing machine.</p>
  
  <p>I am a noob on networking and this kind of things. </p>
  
  <p>Thanks in advance.</p>