Ich mache einen Python-Server auf meinem Computer und Java-Socket-Client läuft auf meinem Handy. Sobald das Java versucht, eine Verbindung herzustellen, friert die App ein. Nichts im Logcat sagen. Ich habe keine Ahnung, warum ...Python-Socket-Server und Java-Android-Socket - Freezes App
Python 3.5.1:
PORT = 8888
import socket
sock = socket.socket()
sock.bind(("0.0.0.0", PORT))
sock.listen(1)
client = None
while not client:
try:
client = sock.accept()
except:
pass
print(client[1])
java:
static String get_leaderboard() {
Socket sock;
OutputStream out;
InputStream in;
try {
System.out.println("now trying to connect");
sock = new Socket("192.168.1.29", 8888);
System.out.println("connected successfuly");
out = sock.getOutputStream();
in = sock.getInputStream();
return Integer.toString(in.read());
} catch (IOException e) {
e.printStackTrace();
}
return "Error in connection";
aber eigentlich logcat nie Prints "verbunden successfuly". nur "versuchen zu verbinden".
Dank, fest ich es, aber es wird immer noch nicht funktioniert –