the terminal return :
E/AndroidRuntime: FATAL EXCEPTION: Thread-7
Process: com.example.tbvv1148.myapplication, PID: 19173
java.net.SocketException: Permission denied
at java.net.Socket.createImpl(Socket.java:454)
at java.net.Socket.(Socket.java:423)
at java.net.Socket.(Socket.java:243)
at com.example.tbvv1148.myapplication.TCPClient.run(MainActivity.kt:71)
at com.example.tbvv1148.myapplication.MainActivity$t$1.invoke(MainActivity.kt:25)
at com.example.tbvv1148.myapplication.MainActivity$t$1.invoke(MainActivity.kt:18)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:18)
02-16 13:14:40.818 19173-19173/? E/ViewRootImpl@b87189c[MainActivity]: ViewRootImpl #2 Surface is not valid.
There is a permission denied but i do not understand what is it
So this is going to be a bit longer. I’m going to also explain how I found this so you can do this yourself the next time you run into a problem like this.
After a bit of googling (“java socket Exception Permission denied”) I found out that for some reason the security manager did allow you to connect to that socket, obviously
Another thing you should look at are android permissions. I guess you are running on android based on your Exception. Android apps as far as I know need to request permissions for a lot of operations so I would look into that:
Those are the links I found with just a few google searches. I am not an android developer so I can’t really help you more, but I think those links should give you a good starting point. If you find some tutorials, they might help as well. Just be sure you don’t follow them blindly, because security is always a hard thing to get right and should not be taken lightly, but than I don’t know what you are trying to do
One of the hardest thing in programming is too learn how to google. It sounds stupid but knowing which keywords to use to find the right answers is extremely helpful. IMO asking on forums should be the step once you can no longer find an answer. (and btw, most questions have already been asked and answered )