title: How to get data to/from a socket in a thread?
body: <p>Android noob here. I learn the best by seeing the source code of a functional example, but I have been unable to find a simple-but-complete example of using a socket in its own thread.</p>
  
  <p>I have an Android service that needs to communicate with the Internet. I want to open a TCP socket that connects to a server on the Internet. The service needs to send data to the Internet, and data coming back from the net will need to go to the service. Since the service is doing other things as well, the socket connection needs to live in its own thread.</p>
  
  <p>Any idea where I could find an example of a socket in a thread with communication to/from the socket?</p>
  
  <p>Thanks</p>
  
  <p><img src="https://i.stack.imgur.com/riPex.gif" alt="enter image description here"></p>