Hello everyone, I have problem with my simple android chat program when using different test debugging.
I have two android emulators one reads SERVERPORT as 8080 and CLIENTPORT as 8082 and the other android emulator reads SERVERPORT as 8082 and CLIENTPORT as 8080 from a given txt file. Here there is no problem and these two emulators can send text message between them **but when I press connect button before press send button at both 2 emulators ** I connect both of them with each other, after that 5-10 s, I catch exception named java.io.EOFException what would be cause that here the code of server side
if (in == null)
in = new DataInputStream(socket.getInputStream());
String line;
while ((line = in.readUTF()) != null) {
Log.e("Above Sleep ServerActivity", line);
Thread.sleep(600);
Log.d("ServerActivity", line);
received_text=line;
handler.post(new Runnable() {
public void run() {
text.append("\nServer Activity: "+received_text);
}
});
}
in.close();
this while line line:6 where I got problem and here the code of client /send button part:
try
{
if (out == null)
{
out = new DataOutputStream(socket.getOutputStream());
}
out.writeUTF(str);
out.flush();
Log.i("Client", "Client sent message");
}
catch ...