I don't want to waste your time, this isn't really THAT important. My code wasn't working and now it does because of one simple change. But I don't understand what that change does. So the following is about that:
I've been struggling with writing my own (simpler) version of a client/server "program" using THIS
Very simple really, just something that would say "hi" and "hello" back and forth.
When I tried the code in the example, it worked fine. But when I wrote my own code, both the client and server programs would run, but nothing happens! When I come to close either program, I'll get an error at the while loop of the other program (Seems like both programs are just infinitely looping there).
Turns out I was omitting the bolded part of the following line when creating a PrintWriter object:
out = new PrintWriter(socket.getOutputStream(), true);
So now the code works, but why? I looked into the API, and it mentions "line flushing", but what is that exactly? I'm assuming it means erasing the contents of the writer every time I write something new! If that's the case shouldn't my code have gone the while loop at least once before getting some sort of error?