F
FilexBB
I compose a client program that capture System.in and send it to
socket as following, it work for server that can receive what client
sent to
1: Socket s = new Socket("localhost", 12345);
2: BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
3: PrintWriter pw = new PrintWriter(s.getOutputStream(), true);
4: //BufferedWriter bw = new BufferedWriter(new
OutputStreamWriter(s.getOutputStream()));
5: String str = br.readLine();
6: pw.println(str);
7: //bw.write(str);
8: //bw.flush();
But if comment line 3 and 6 and uncomment line 4, 7 and 8, it doesn't
work on server that can't recieve anything. My question is why it work
on PrintWriter with set to flush at constructor level, but not work
for BufferedWriter method ".flush()". Hope to clarify it.
Regards,
FilexBB
socket as following, it work for server that can receive what client
sent to
1: Socket s = new Socket("localhost", 12345);
2: BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
3: PrintWriter pw = new PrintWriter(s.getOutputStream(), true);
4: //BufferedWriter bw = new BufferedWriter(new
OutputStreamWriter(s.getOutputStream()));
5: String str = br.readLine();
6: pw.println(str);
7: //bw.write(str);
8: //bw.flush();
But if comment line 3 and 6 and uncomment line 4, 7 and 8, it doesn't
work on server that can't recieve anything. My question is why it work
on PrintWriter with set to flush at constructor level, but not work
for BufferedWriter method ".flush()". Hope to clarify it.
Regards,
FilexBB