title: Unable to connect to other device via socket
body: <p>I am working on a wireless file sharing app. I have created 2 different AsyncTasks, one for sending and one for receiving. 
  In the class used for sending the data, Here is a snippet of the code I use for connecting.</p>
  
  <pre><code>client = new Socket();
  client.bind(null);
  client.connect(new InetSocketAddress(groupOwnerAddress, 8888));
  </code></pre>
  
  <p>In the class used for receiving the data, I create a ServerSocket and a Socket and then call</p>
  
  <pre><code>server = new ServerSocket(8888);
  client = server.accept();
  </code></pre>
  
  <p>My devices aren't connecting to each other for some reason. In the device that I am sending the data from, I get the following message in the log. </p>
  
  <p>I am pretty certain that my IP address is not wrong because I connected the 2 devices using WifiP2pManager's connect() method. I then got the IP address using by requesting the group information. </p>
  
  <pre><code>java.net.ConnectException: failed to connect to /192.168.49.1 (port 8888) from /:: (port 38275): connect failed: ECONNREFUSED (Connection refused)
  </code></pre>
  
  <p>The error points to this line </p>
  
  <pre><code>client.connect(new InetSocketAddress(groupOwnerAddress, 8888));
  </code></pre>
  
  <p>I looked up the error online and it said that the port is not listening.. But when i debug the receiving device, I can see that the debugger stops at this line </p>
  
  <pre><code>client = server.accept();
  </code></pre>
  
  <p>From what I can understand, this means that the device is listening on the port.</p>
  
  <p>Any help is appreciated. </p>