title: Android new Socket error
body: <p>I am trying to create a WiFi connection between a raspberry pi and an android device. I am a beginner in setting up WiFi connections but have found some online code which to establish the connection. Here server C code running on the pi:</p>
  
  <pre><code>double C[SIZE];
  char D[SIZE];
  bool bResult = false;
  
  /* if no command line arguments passed, we'll default to 
      these two port number */
  
  int port = 5710;
  int dataport = -1;
  
  if (argc &gt; 1)
  {
      port = atoi(argv[1]);
  
      if (argc &gt; 2)
          dataport = atoi(argv[2]);
  }
  
  printf("Server, listening on port %d, datagram port %d\n", port, dataport);
  fflush(NULL);
  
  Server mylink(port, dataport, &amp;bResult);
  if (!bResult)
  {
      printf("Failed to create Server object!\n");
      return 0;
  }
  
  /* put some dummy data in our arrays */
  
  for (int i = 0; i &lt; SIZE; i++)
  {
      C[i] = (double) i*i+0.5;
      D[i] = i;
  }
  printf("Server, waiting for connection...\n");
  fflush(NULL);
  mylink.Connect();
  
  printf("Server, got a connection...\n");
  fflush(NULL);
  
  for (int i = 0; i &lt; NUM_PACKS; i++)
  {
      printf("Server, sending bytes, iteration %d...\n", i);
      fflush(NULL);
      mylink.SendBytes(D, SIZE);
  
      printf("Server, receiving doubles, iteration %d...\n", i);
      fflush(NULL);
      mylink.RecvDoubles(C, SIZE);
  }
  
  printf("Server, closing connection...\n");
  fflush(NULL);
  mylink.Close();
  
  printf("Server, done...\n");
  fflush(NULL);
  return 0;
  </code></pre>
  
  <p>And here is the android code to connect to the raspberry server:</p>
  
  <pre><code>Socket myClient = new Socket("192.168.XXX.XXX", 5710);
  SocketAddress remotAddrr = new InetSocketAddress("192.168.XXX.XXX", 5710);  
  myClient.connect(remotAddr,10000);
  booleanfeedbackconnec = myClient.isConnected();
  int feedbackgetport = myClient.getPort();
  </code></pre>
  
  <p>I think the problem with the code is this line:</p>
  
  <pre><code>Socket myClient = new Socket("192.168.XXX.XXX", 5710);
  </code></pre>
  
  <p>It tends to throw an exception or sometimes just stops the application. I have requested the permissions on the manifest file but cant figure out whats wrong with this line</p>
  
  <p>Thanks</p>