Koska
Koska

Reputation: 131

Python PermissionError: [Errno 13] Permission denied using Socket

I have two scripts, the server is running on my pc and if it gets a connection, than my computer shuts down. The client script is on my Android phone and, in theory, it connect to my computer.

With Buildozer on Ubuntu I've made an apk file, and if I run it on my phone than nothing happens. But if I connect to the server, from the browser on my phone, than it works. And from a Python IDE for Android (QPython3) it also works, if I run the script from there.

client.py

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

HOST = "192.168.0.103"
PORT = 5000

s.connect((HOST, PORT))

I've tested the apk with Android Studio and it throw this error:

Traceback (most recent call last):
File "/home/admin1/ComputerOff/.buildozer/android/app/main.py", line 3, in <module>
File "/home/admin1/ComputerOff/.buildozer/android/platform/build/build/other_builds/python3-libffi-openssl-sqlite3/armeabi-v7a__ndk_target_21/python3/Lib/socket.py", line 151, in __init__
PermissionError: [Errno 13] Permission denied

I've looked up this error on the internet and I only find that ports over 1024 works for this purpose, but I've already had higher port, so it didn't help much. I hope that someone can help.

Upvotes: 2

Views: 1904

Answers (1)

Azzou Groun
Azzou Groun

Reputation: 11

You need to add Network permissions inside your manifest add this:

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

Upvotes: 1

Related Questions