I have troubles with socket connection of PC (simple server written on Java) and android emulator. Connection is established, server sends data but when I try to read it on android it always reads a null-string. Here is some parts of my code:
Server:
serverSocket = new ServerSocket(8888);
socket = serverSocket.accept();
PrintWriter output = new PrintWriter(socket.getOutputStream(), true);
output.write("Output string");
socket.close();
Client:
socket = new Socket("10.0.2.2", 8888);
input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String s = input.readLine();
Log.i(TAG, s);
socket.close();
I've omitted try-catches and logs for clearness. According to logs, connection is established, server sends data, but client receives only null-strings. I'd appreciate any help.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)