socket failed: EACCES (Permission denied)

1

I was creating an Android project that made him communicate with a Windows machine via Sockets, the machine being the server, and the mobile device (Samsung Galaxy S3 MINI) the client.

I created a hosted wireless network on the computer, and connected the device to the PC via USB cable, but I connected to the wireless network I created on the computer.

I made when there was an error, the error was written to a TextView, and returned the error:

socket failed: EACCES (Permission Denied)

Activity Code: link

ManiFest.xml link

    
asked by anonymous 10.05.2014 / 22:49

1 answer

2

There are some details in your code.

In the manifest, the line

<permission  android:name="android.permission.INTERNET"/>

Should be

<uses-permission android:name="android.permission.INTERNET" />

As for the Activity code, when you create an instance of class Socket , you are creating a TCP / IP connection to any destination, which in the case of your code is the cell itself:

socket = new Socket("127.0.0.1",5000);

The IP 127.0.0.1 , referring to the own machine / device (is the IP of loopback ), that is, you would not be connecting to the computer that way. You should replace this IP with your computer's IP.

In addition, you should ensure that there is some program / service on the computer, "listening" on port 5000, otherwise the connection will also fail.

    
11.05.2014 / 15:22