user1279563
user1279563

Reputation: 77

Socket based PrintWriter doesn't flush, just after close()

I am writing a server-client application.

The problem is, that in the server the PrintWriter doesn't flush after some point, just after I close the print writer. But if I close the print writer, it closes the socket as well, however I need to use it later.

How can I solve this?

pw = new PrintStream(socket.getOutputStream());
pw.println("igyulibigyuli");
pw.flush();

It doesn't flush, just if I close the printwriter after the flush.(Or if I close the program!)

Upvotes: 0

Views: 1667

Answers (1)

user1279563
user1279563

Reputation: 77

The problam was that the socket was busy reading(in a while loop, till it get not null).

Upvotes: 0

Related Questions