title: Connection refused - socket
body: <p>I'm creating an android app. It requires a TCP socket connection to send data to the another device.</p>
  
  <p>Everything works fine for the first time transfer. However when I connect it the second time, it says connection refused by the host or bind error.</p>
  
  <p>I did all possible things to solve this bind error and connection refused. I shutdown both reading and writing end once the transfer is complete, set socket option to re use address, lingering option.</p>
  
  <p>These things work fine when I exit the application completely and open it again but it does not work when I try to open the connection without exiting.</p>
  
  <p>Kindly, help me figure out whether the problem is something related with sockets or with the application, and any ideas how this could be solved?</p>