title: Initializing network connection in Service
body: <p>I'm trying to implement Service to manage network in my app. This service would be used to communicate with an external server from several activities. </p>
  
  <p>How and when should I initialize connection to the server? I thought about doing this in service's onCreate method like this:</p>
  
  <pre><code>@Override
  public void onCreate() {
      new Thread(new Runnable() {
          @Override
          public void run() {
              try{
                  socket = new Socket(HOST, PORT);
  
                  ... 
              }
              catch(IOException e){
                 // How to manage this exception?
              }
          }
      });
  } 
  </code></pre>
  
  <p>But if connection error would occur how could I tell that to a client (activity which calls this service) ?</p>