title: Why I cannot connect android and PC through socket?
body: <p>I just started my first android application and have some troubles. I already have server code written in C++ in Qt. Since now I was using another console application as a client and everything works correctly. Now I'm trying to make a client part on my android (Android Studio). I want the client to be connected when I'll press the button. Only connection - no data exchange etc. When client (android) will be connected server should display communicate. 
  Here is how my server connecting func. looks like:</p>
  
  <pre><code> SUCCESSFUL = WSAStartup(MAKEWORD(2,1), &amp;WinSockData);
   sock_CONNECTION= socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   memset(&amp; ADDRESS, 0, sizeof(ADDRESS));
   ADDRESS.sin_addr.s_addr = inet_addr("127.0.0.1");
   ADDRESS.sin_family = AF_INET;
   ADDRESS.sin_port = htons(9090);
  
  void Server::Connect()
  {
  bind(sock_CONNECTION, (SOCKADDR*)&amp;ADDRESS, sizeof(ADDRESS));
  listen(sock_CONNECTION,1);
  SOCKET accept_Socket =0;
  while(accept_Socket==0)
  {
      accept_Socket = accept(sock_CONNECTION, NULL, NULL);
  }
  std::cout &lt;&lt; "Client connected" &lt;&lt; std::endl;
  sock_CONNECTION=accept_Socket;
  }
  </code></pre>
  
  <p><strong>UPDATE:</strong> /I changed IP as you said in a comment/ </p>
  
  <p>Client's code. There are no fatal errors, just application is doing nothing. 
  Code:</p>
  
  <pre><code>Socket socket;
    public void onClick(View v) {
                  try {
                      socket = new Socket("192.168.0.227", 9090);
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
  </code></pre>
  
  <p>Errors:</p>
  
  <pre><code>Failed to set EGL_SWAP_BEHAVIOR on surface 0xaa23f380, error=EGL_SUCCESS
  java.net.SocketException: socket failed: EACCES (Permission denied)
      at libcore.io.IoBridge.socket(IoBridge.java:619)
      at java.net.PlainSocketImpl.create(PlainSocketImpl.java:198)
      at java.net.Socket.startupSocket(Socket.java:584)
      at java.net.Socket.tryAllAddresses(Socket.java:128)
      at java.net.Socket.&lt;init&gt;(Socket.java:178)
      at java.net.Socket.&lt;init&gt;(Socket.java:150)
      at com.example.nataliah.client_testapp.Client_Connection$1.onClick(Client_Connection.java:26)
      at android.view.View.performClick(View.java:5198)
      at android.view.View$PerformClick.run(View.java:21147)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5417)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  Caused by: android.system.ErrnoException: socket failed: EACCES (Permission denied)
      at libcore.io.Posix.socket(Native Method)
     at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:282)
     at libcore.io.IoBridge.socket(IoBridge.java:604)
  </code></pre>
  
  <p><strong>UPDATE 2</strong> After adding permission to network I received those errors + the old ones:</p>
  
  <pre><code>android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
                                                                                         at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:110)
                                                                                         at libcore.io.IoBridge.connectErrno(IoBridge.java:137)
                                                                                         at libcore.io.IoBridge.connect(IoBridge.java:122)
                                                                                         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
                                                                                         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:163)
  </code></pre>