BufferedReader
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bob_McGarvey
Posted On:   Wednesday, June 19, 2002 02:44 PM

I am working with BufferedReaders and OutputStreamWriters during a socket connection. The problem I have is that the server I connect to doesn't send any terminating characters for the end of the buffer. Any ideas on how to make this work. I send data and receive data. Then send another packet but am not able to recieve the data. inpt is a file. out = new OutputStreamWriter(rwSocket.getOutputStream(), "cp500"); in = new BufferedReader(new InputStreamReader( rwSocket.getInputStream(), "cp500")); try { while ((userInput = inpt.readLine()) != null) { out.write(userInput,0,userInput.length()); System.out.println("User Input : " + userInput); out.flush();    More>>

I am working with BufferedReaders and OutputStreamWriters during a socket connection. The problem I have is that the server I connect to doesn't send any terminating characters for the end of the buffer. Any ideas on how to make this work. I send data and receive data. Then send another packet but am not able to recieve the data. inpt is a file.


			

out = new OutputStreamWriter(rwSocket.getOutputStream(), "cp500");
in = new BufferedReader(new InputStreamReader( rwSocket.getInputStream(), "cp500"));
try {

while ((userInput = inpt.readLine()) != null) {

out.write(userInput,0,userInput.length());
System.out.println("User Input : " + userInput);
out.flush();

while ((charsRead = in.read(buffr)) != -1){

System.out.println("charsRead " + charsRead);
System.out.println(buffr);
}
}
   <<Less

Re: BufferedReader

Posted By:   Lunkwill_Vroomfondel  
Posted On:   Thursday, June 20, 2002 12:13 PM

you should invent your own protocol for these connections.



with this protocol you should provide the possibility to encounter sth. like "its your turn now - im done"...



of course you would have to change your while-conditions (at least the second one).



more help for more info.
About | Sitemap | Contact