• Post Reply Bookmark Topic Watch Topic
  • New Topic

why my client program will not respond when a string "1" is sent by my server program  RSS feed

 
pk srinivasan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MY client program will not respond when a string "1" is sent from the server. If the server sends some other message it responds properly the code is given
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea what you are doing with this code, but I ask you: Why do you pass an InputStream to the InputThread1 constructor when you don't use it?

What response do you expect when "1" is received?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

I won't trace through your whole program and give you a definitive answer, but you are doing something that can easily lead to this sort of problem: if you attach a BufferedReader (or in general, any buffered input stream or reader) to a data source, then all input must be read through that BufferedReader. That's because the BufferedReader reads more input than it needs and stores it internally (that's the whole point of buffering!) If you try to read directly from the original stream, as you're doing here, then you'll find that some of the data you expect is "missing" -- it will be inside of the BufferedReader.

So call getInputStream() once, construct your BufferedReader, and then from then on read all of your input through that BufferedReader.

I'm moving this to our I/O and Streams forum for any further discussion.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!